Getting Started
Starter Template and an Example Program for pyDraw
Now that we have pydraw installed, we can write a base program:
1
from pydraw import *
2
3
screen = Screen(800, 600)
4
5
# code goes here!
6
7
screen.stop()
Copied!
Note that you could also replace line 7 with this to support animation:
1
fps = 30
2
running = True
3
while running:
4
screen.update()
5
screen.sleep(1 / fps)
Copied!

Example Program

We can go ahead and add some shapes:
1
from pydraw import *
2
3
screen = Screen(800, 600)
4
5
box = Rectangle(screen, 50, 50, 50, 50)
6
triangle = Triangle(screen, 150, 150, 50, 50)
7
circle = Oval(screen, 250, 250, 50, 50)
8
hexagon = Polygon(screen, 6, 350, 350, 50, 50)
9
10
screen.stop()
Copied!
And the following output will be produced:
Output for the Example Above
Last modified 7mo ago
Copy link