|
Eb303 |
at Oct 8, 2009 at 7:30 am
|
⇧ |
| |
On Oct 8, 12:40 am, J Wolfe wrote:
What's the best way to make a realtime loop in Tkinter? I know in
perl you can use "repeat" and it will call a function every x seconds,
in python it seems like "after" may be the equivalent though it
doesn't seem to behave like the perl repeat function. Any ideas?
Thanks,
Jonathan
Well, I don't know the Perl 'repeat' function, but AFAICT, after seems
to be the way to go in Tkinter. Maybe something like this:
---
from Tkinter import *
root = Tk()
var = IntVar()
def incr():
var.set(1 + var.get())
root.after(1000, incr)
Label(root, width, textvariable=var).pack()
Button(root, text='Go!', command=incr).pack()
root.mainloop()
---
HTH