-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpoly.py
33 lines (26 loc) · 834 Bytes
/
poly.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# poly.py
from graphics import *
def main():
#Introduction
#Draw a polygon from mouse clicks
win = GraphWin("Draw a Polygone",400,300)
win.setCoords(0.0, 0.0, 10.0, 10.0)
message = Text(Point(5,0.5), "Click on n points")
message.draw(win)
n = int(input('Enter number of sides: '))
#Get and draw vertices of polygon
l = [] #empty list to store points
for i in range(1,n+1):
p = win.getMouse()
l.append(p) # populate your list with the points
p.draw(win)
#Use Polygon objectto to draw the triangle
P = Polygon(l) #create your polygone given the list of points
P.setFill("blue")
P.setOutline("red")
P.draw(win)
#Wait for another click to exit
message.setText("Click anywhere to quit.")
win.getMouse()
win.close()
main()