[Tutor] Is there a way to force update the screen in tkinter?
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Tue Jan 11 01:53:11 CET 2005
On Mon, 10 Jan 2005, R. Alan Monroe wrote:
> I don't have the code here at home, but today I tried my first
> experiments in Tkinter. I set up a button that fired off a function to
> resize a rectangle in a canvas, with a for loop. Only problem is that
> the screen isn't repainted in all the steps of the for loop - only at
> the very end, when the rectangle is at its final, largest size. Can I
> make it repaint DURING the loop?
Hi Alan,
Yes, Tkinter queries up a bunch of events to refresh the window, but
doesn't execute them directly until it has a chance to take control, that
is, when control passes back into the mainloop.
You can manually force a refresh of the window-refreshing events through
the loop. Use update_idletasks() methods on the toplevel Tk, and it
should refresh things properly. See:
http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm
which talks about it a little more.
Hope this helps!
More information about the Tutor
mailing list