What I want to be able to do is click on the frame window so that points will appear on it and when I click in the rectangle that says 'Done' for the program to stop. However the program keep going when I click inside the rectangle. Here IS the code I have so far:
def main():
print(" Click anywhere in graph window ten times to get points")
win=GraphWin("regression line", 300,300)
rect= Rectangle(Point(5,5), Point(90,95))
rect.draw(win)
label= Text( Point(30,50), "Done")
label.draw(win)
while True:
click_point=win.getMouse()
mouse= click_point
click_x=mouse.getX()
click_y=mouse.getY()
p1=rect.getP1()
p2=rect.getP2()
rect_x1, rect_y1= p1.getX(), p1.getY()
rect_x2, rect_y2= p2.getX(), p1.getY()
mouse.draw(win)
if (rect_x1<=click_x<=rect_x2) and (rect_y1<=click_y<=rect_y2): break
Larz60+ write Dec-06-2025, 06:37 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button. I have aded bbcode tags for youthis time.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button. I have aded bbcode tags for youthis time.
