#polygon0.py
"""Display polygon only once.
Interactively chose polygon vertices, with total entered in shell.
Illustrates use of Text, Polygon, getMouse.
"""

from graphics import *

def main():
    width = 300
    height = 300
    infoHeight = 15
    size = input("Enter the number of sides:  ")
    win = GraphWin("%d Sides" % size, width, height)
    instructions = Text(Point(width/2, infoHeight),
                     "Click %d vertices:" % size)
    instructions.draw(win)
    
    vertices = []
    for i in range(size): 
        pt = win.getMouse()
        pt.draw(win)
        vertices.append(pt) # append method adds to the list

    poly = Polygon(vertices)  
    poly.draw(win)
    instructions.setText("Click anywhere to quit.")
    win.getMouse()
    win.close()

main()
