[Tkinter-discuss] Forcing a window to update with while loop running
Adam Kadzban
mightyshortadam at gmail.com
Thu Jun 18 22:34:38 CEST 2009
Hi again, let me start off by saying that my code does what I want it to,
it's just done in a terribly hackish way, and I'm wondering if there's a
better way to do it.
I've got a Tkinter window, and when you click a button (the 'run' button),
it opens a new window. When the new window opens, it starts running events
in a while loop, and there's a 'stop' button on the window. The stop button
just turns the 'while' condition variable to 0, so the loop ends. Here's a
quick sketch of how I got it to work:
...
loop = 1
...
(create a button that sets loop to 0)
...
top.update()
...
while loop:
top.update()
...do stuff...
top.update()
This works, but I feel like there's got to be a better way to be doing
this. I can get rid of the first top.update(), and one of the updates in
the loop, but this configuration seems to be the most responsive. And using
update_idletasks() doesn't seem to work, at all.
Anyone have an idea?
-Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20090618/e26b3adc/attachment.htm>
More information about the Tkinter-discuss
mailing list