Emeka wrote:
> I am putting together a small game, and I would want to enable my callback
> function using time passed.
>
> How to do something like this with Tkinter event.
>
> from time import time
>
> ftime = time()
> if ftime - time() > 2000:
> dosomething
You can schedule a function call with the after() method:
import Tkinter as tk
def scroll(s):
while True:
yield s
s = s[-1] + s[:-1]
hello = scroll("Hello world! *** ")
def do_something():
label["text"] = next(hello)
# play it again, after 100 msecs
label.after(100, do_something)
root = tk.Tk()
label = tk.Label(root, font=("Times", 36))
label.pack()
do_something()
root.mainloop()
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor