from time import sleep from graphics import * # importing all the commands from graphics library, # for direct use def main(): win=GraphWin("Just Playing around with points and shapes",800,600) # creates a window p1=Point(400,500) # create a point that will be the center of the wheel1 p2=Point(600,500) # create a point that will be the center of the wheel2 wheel1 = Circle(p1,20) wheel1_1=Circle(p1,10) wheel2_1=Circle(p2,10) wheel2 = Circle(p2,20) p1.draw(win) # draw point p1 p2.draw(win) # draw point p2 wheel1.draw(win) wheel2.draw(win) wheel1_1.draw(win) wheel2_1.draw(win) p1_x=p1.getX() # get the x-coordinate of point p1 p1_y=p1.getY() # get the y-coordinate of point p1 p2_x=p2.getX() # get the x-coordinate of point p2 p2_y=p2.getY() # get the y-coordinate of point p2 print("The x-coordinate of the first point is ", p1_x) print("the y-coordinate is ",p1_y) print("The x-coordinate of the second point is ", p2_x) print("the y-coordinate is ",p2_y) R = Rectangle(Point(350,400),Point(650,480)) R.draw(win) treeTrunk = Line(Point(200,40),Point(200,500)) treeTop = Polygon(Point(100,80),Point(200,40),Point(300,80)) treeMiddle = Polygon(Point(50,180),Point(200,100),Point(350,180)) treeBottom = Polygon(Point(10,380),Point(200,240),Point(400,380)) treeB = Line(Point(180,500),Point(220,500)) treeTrunk.draw(win) treeTop.draw(win) treeMiddle.draw(win) treeBottom.draw(win) treeB.draw(win) x=input("Press any key and then enter to continue:") print("Now, let's add some color...") treeTop.setFill("green") treeMiddle.setFill("green") treeBottom.setFill("green") wheel1.setFill("yellow") wheel1_1.setFill("blue") wheel2.setFill("yellow") wheel2_1.setFill("blue") R.setFill("blue") T = Text(Point(400,550),"Hello, do you like it?") T.setSize(22) T.draw(win) T1 = Text(Point(600,70),"Click anywhere") T1.setSize(22) T1.draw(win) win.getMouse() wheel1.undraw() wheel1_1.undraw() wheel2.undraw() wheel2_1.undraw() R.undraw() treeTop.undraw() treeMiddle.undraw() treeBottom.undraw() T.undraw() T1.setText("Bye bye!") sleep(2) win.close() main()