3 # This program shows how to use the "after" function to make animation.
9 def createWidgets(self
):
10 self
.QUIT
= Button(self
, text
='QUIT', foreground
='red',
12 self
.QUIT
.pack(side
=LEFT
, fill
=BOTH
)
14 self
.draw
= Canvas(self
, width
="5i", height
="5i")
17 self
.draw
.create_rectangle(0, 0, 10, 10, tags
="thing", fill
="blue")
18 self
.draw
.pack(side
=LEFT
)
20 def moveThing(self
, *args
):
21 # move 1/10 of an inch every 1/10 sec (1" per second, smoothly)
22 self
.draw
.move("thing", "0.01i", "0.01i")
23 self
.after(10, self
.moveThing
)
26 def __init__(self
, master
=None):
27 Frame
.__init
__(self
, master
)
30 self
.after(10, self
.moveThing
)