# File: exp6.py # # Simple test of graphics module from textbook # See documentation in: # # http://mcsp.wartburg.edu/zelle/python/graphics/graphics/graphics.html # # Same as exp5.py, except the orange square # marches off the screen. from graphics import * import time def drawBox(x, y, color): box = Rectangle(Point(x,y), Point(x+20,y+20)) box.setFill(color) box.setWidth(0) box.draw(win) # make a window for drawing stuff win = GraphWin("Hello", 500, 500) # initial point x = 0 y = 240 # Draw first box drawBox(x,y,"orange") # Iterate a lot for i in range(40): # erase old box drawBox(x,y,"white") x = x + 20 # draw new box drawBox(x,y,"orange") time.sleep(.2) # end of for i # wait before closing window time.sleep(60) # make the window go away win.close()