######################################################################## # similar, but with .after scheduled events, not time.sleep loops; # because these are scheduled events, this allows both ovals and # rectangles to be moving at the _same_ time and does not require # update calls to refresh the gui (only one time.sleep loop callback # can be running at once, and blocks others started until it returns); # the motion gets wild if you press 'o' or 'r' while move in progress, # though--multiple move updates start firing around the same time; ######################################################################## from Tkinter import * import canvasDraw_tags class CanvasEventsDemo(canvasDraw_tags.CanvasEventsDemo): def moveEm(self, tag, moremoves): (diffx, diffy), moremoves = moremoves[0], moremoves[1:] self.canvas.move(tag, diffx, diffy) if moremoves: self.canvas.after(250, self.moveEm, tag, moremoves) def moveInSquares(self, tag): allmoves = [(+20, 0), (0, +20), (-20, 0), (0, -20)] * 5 self.moveEm(tag, allmoves) if __name__ == '__main__': CanvasEventsDemo() mainloop()