append(): Fixing the test for convertability after consultation with
[python/dscho.git] / Demo / tkinter / matt / animation-w-velocity-ctrl.py
bloba45f3f0e8a6bdd3e060c1186af3d334edd4b51ef
1 from Tkinter import *
3 # this is the same as simple-demo-1.py, but uses
4 # subclassing.
5 # note that there is no explicit call to start Tk.
6 # Tkinter is smart enough to start the system if it's not already going.
9 class Test(Frame):
10 def printit(self):
11 print "hi"
13 def createWidgets(self):
14 self.QUIT = Button(self, text='QUIT', foreground='red',
15 command=self.quit)
16 self.QUIT.pack(side=BOTTOM, fill=BOTH)
18 self.draw = Canvas(self, width="5i", height="5i")
20 self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100)
22 self.speed.pack(side=BOTTOM, fill=X)
24 # all of these work..
25 self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue")
26 self.draw.pack(side=LEFT)
28 def moveThing(self, *args):
29 velocity = self.speed.get()
30 str = float(velocity) / 1000.0
31 str = `str` + "i"
32 self.draw.move("thing", str, str)
33 self.after(10, self.moveThing)
35 def __init__(self, master=None):
36 Frame.__init__(self, master)
37 Pack.config(self)
38 self.createWidgets()
39 self.after(10, self.moveThing)
42 test = Test()
44 test.mainloop()