diff options
author | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@localhost> | 2011-05-03 11:25:13 +0000 |
commit | 458120dd40db6b4df55a4e96b650e16798ef06a0 (patch) | |
tree | 8f82685be24fef97e715c6f5ca4c68d34d5074ee /sys/src/cmd/python/Demo/tkinter/matt/animation-w-velocity-ctrl.py | |
parent | 3a742c699f6806c1145aea5149bf15de15a0afd7 (diff) |
add hg and python
Diffstat (limited to 'sys/src/cmd/python/Demo/tkinter/matt/animation-w-velocity-ctrl.py')
-rw-r--r-- | sys/src/cmd/python/Demo/tkinter/matt/animation-w-velocity-ctrl.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sys/src/cmd/python/Demo/tkinter/matt/animation-w-velocity-ctrl.py b/sys/src/cmd/python/Demo/tkinter/matt/animation-w-velocity-ctrl.py new file mode 100644 index 000000000..e676338fe --- /dev/null +++ b/sys/src/cmd/python/Demo/tkinter/matt/animation-w-velocity-ctrl.py @@ -0,0 +1,44 @@ +from Tkinter import * + +# this is the same as simple-demo-1.py, but uses +# subclassing. +# note that there is no explicit call to start Tk. +# Tkinter is smart enough to start the system if it's not already going. + + +class Test(Frame): + def printit(self): + print "hi" + + def createWidgets(self): + self.QUIT = Button(self, text='QUIT', foreground='red', + command=self.quit) + self.QUIT.pack(side=BOTTOM, fill=BOTH) + + self.draw = Canvas(self, width="5i", height="5i") + + self.speed = Scale(self, orient=HORIZONTAL, from_=-100, to=100) + + self.speed.pack(side=BOTTOM, fill=X) + + # all of these work.. + self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue") + self.draw.pack(side=LEFT) + + def moveThing(self, *args): + velocity = self.speed.get() + str = float(velocity) / 1000.0 + str = "%ri" % (str,) + self.draw.move("thing", str, str) + self.after(10, self.moveThing) + + def __init__(self, master=None): + Frame.__init__(self, master) + Pack.config(self) + self.createWidgets() + self.after(10, self.moveThing) + + +test = Test() + +test.mainloop() |