• Profile photo of Ben nan

      Ben nan posted an update

      4 days ago

      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 keeps 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