This should finally fix #6896. Let's watch the buildbots.
[python.git] / Demo / tkinter / matt / animation-simple.py
blobb52e1dc3aed98df3dc986755c65ddd66bdb7db8d
1 from Tkinter import *
3 # This program shows how to use the "after" function to make animation.
5 class Test(Frame):
6 def printit(self):
7 print "hi"
9 def createWidgets(self):
10 self.QUIT = Button(self, text='QUIT', foreground='red',
11 command=self.quit)
12 self.QUIT.pack(side=LEFT, fill=BOTH)
14 self.draw = Canvas(self, width="5i", height="5i")
16 # all of these work..
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)
28 Pack.config(self)
29 self.createWidgets()
30 self.after(10, self.moveThing)
33 test = Test()
35 test.mainloop()