I'm trying to update an Entry's textvariable several times within my Button 
handler, like so:

from Tkinter import *
from time import *

def my_update():
   for i in range(3):
     tv.set("Now it's %d"%i)
     sleep(1)

root=Tk()
tv=StringVar()
Entry(textvariable=tv).pack()
tv.set("Initial Value of StringVar")
Button(text="Update", command=my_update).pack()
root.mainloop()


What happens when I hit the Update button is a 3-second pause, then "Now it's 
2" is displayed.

What I expected to see in the Entry was:

"Now it's 0"  (right away)
"Now it's 1"  (after 1 second pause)
"Now it's 2"  (after another 1 second pause)


Any idea what's going on here?  Why doesn't "tv.set("<stuff>") happen 
immediately?

Thanks, -Mike

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to