changes by Barry, e.g. font lock & email addresses
[python/dscho.git] / Demo / tkinter / matt / animation-simple.py
blob015879311d3d086fb2ef1e0dff0efa73a5a116d4
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',
11 'fg': 'red',
12 'command': self.quit})
13 self.QUIT.pack({'side': 'left', 'fill': 'both'})
15 self.draw = Canvas(self, {"width" : "5i", "height" : "5i"})
17 # all of these work..
18 self.draw.create_polygon("0", "0", "10", "0", "10", "10", "0" , "10", {"tags" : "thing"})
19 self.draw.pack({'side': 'left'})
21 def moveThing(self, *args):
22 # move 1/10 of an inch every 1/10 sec (1" per second, smoothly)
23 self.draw.move("thing", "0.01i", "0.01i")
24 self.after(10, self.moveThing)
27 def __init__(self, master=None):
28 Frame.__init__(self, master)
29 Pack.config(self)
30 self.createWidgets()
31 self.after(10, self.moveThing)
34 test = Test()
36 test.mainloop()