from graphics import * def main(): w = GraphWin("Target",800,600) w.setBackground("lightyellow") r = 200 # drawing dart board for i in range(10): C = Circle(Point(400,300),r-20*i) if i%2 == 1: # odd circles will be colored white C.setFill("white") else: # even circles will be colored white C.setFill("red") C.draw(w) # Creating and drawing the EXIT button button = Rectangle(Point(350,540),Point(450,600)) button.setOutline('green') button.setFill('green') button.draw(w) button_text=Text(Point(400,570),"EXIT") button_text.setSize(22) button_text.draw(w) # waiting for mouse clicks and processing them while True: p = w.getMouse() # getting the mouse click x = p.getX() # storing x-coordinate of the mouse click y = p.getY() # storing y-coordinate of the mouse click # if user clicks on the Exit button if 350 <= x <= 450 and 540 <= y <= 600: break L = Line(Point(x-20,y+20),p) # create a dart L.setArrow("last") # with the arrow at the end L.draw(w) # draw it w.close() main()