Last change
on this file was 2, checked in by Yuri Dario, 15 years ago |
Initial import for vendor code.
|
-
Property svn:eol-style
set to
native
|
File size:
939 bytes
|
Line | |
---|
1 | from Tkinter import *
|
---|
2 |
|
---|
3 | # This program shows how to use the "after" function to make animation.
|
---|
4 |
|
---|
5 | class Test(Frame):
|
---|
6 | def printit(self):
|
---|
7 | print "hi"
|
---|
8 |
|
---|
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)
|
---|
13 |
|
---|
14 | self.draw = Canvas(self, width="5i", height="5i")
|
---|
15 |
|
---|
16 | # all of these work..
|
---|
17 | self.draw.create_rectangle(0, 0, 10, 10, tags="thing", fill="blue")
|
---|
18 | self.draw.pack(side=LEFT)
|
---|
19 |
|
---|
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)
|
---|
24 |
|
---|
25 |
|
---|
26 | def __init__(self, master=None):
|
---|
27 | Frame.__init__(self, master)
|
---|
28 | Pack.config(self)
|
---|
29 | self.createWidgets()
|
---|
30 | self.after(10, self.moveThing)
|
---|
31 |
|
---|
32 |
|
---|
33 | test = Test()
|
---|
34 |
|
---|
35 | test.mainloop()
|
---|
Note:
See
TracBrowser
for help on using the repository browser.