# File: exp4.py # # Simple test of graphics module from textbook # See documentation in: # # http://mcsp.wartburg.edu/zelle/python/graphics/graphics/graphics.html # # Drawing white boxes over an orange one is # like "erasing" the orange box. # # See orange box march across the screen. # from graphics import * import time # make a window for drawing stuff win = GraphWin("Hello", 500, 500) # initial point x = 0 y = 240 # Draw first box box = Rectangle(Point(x,y), Point(x+20,y+20)) box.setFill("orange") box.setWidth(0) box.draw(win) for i in range(10): # "erase" previous box box = Rectangle(Point(x,y), Point(x+20,y+20)) box.setFill("white") box.setWidth(0) box.draw(win) # increase x position x = x + 20 # draw new box box = Rectangle(Point(x,y), Point(x+20,y+20)) box.setFill("orange") box.setWidth(0) box.draw(win) time.sleep(.5) # end of for i # wait before closing window time.sleep(60) # make the window go away win.close()