I am trying to create a program where the user clicks in a window, and this creates a list of stored points that are also drawn in the window. The user can click as many times as they want, but once they click within the rectangle that says "Done" in the lower left, the list is complete.
I have gotten stuck on creating the loop that allows the user to plot the points until they click "Done".
Here is what I have so far (I know I am missing a lot):
from graphics import *
def main():
plot=GraphWin("Plot Me!",400,400)
plot.setCoords(0,0,4,4)
button=Text(Point(.3,.2),"Done")
button.draw(plot)
Rectangle(Point(0,0),Point(.6,.4)).draw(plot)
#Create as many points as the user wants and store in a list
count=0 #This will keep track of the number of points.
xstr=plot.getMouse()
x=xstr.getX()
y=xstr.getY()
if (x>.6) and (y>.4):
count=count+1
xstr.draw(plot)
else: #if they click within the "Done" rectangle, the list is complete.
button.setText("Thank you!")
main()
What is the best way to create a list of stored points from the user clicking within the graphic window? I plan to use these points later, but I just want to get the points stored first.