By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,627 Members | 1,211 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,627 IT Pros & Developers. It's quick & easy.

Redrawing GUI while in a for loop

P: n/a
Hi,
I am making a program which has got some GUI. I need a timer in it which
performs some kind of operations. What I am doing now is something like

while 1:
sleep(1)
do_stuff()

But this way I cannot interact with the GUI since the program is only run
within the while loop. Is there any way to solve the problem either with a
function that temporarily passes control to the OS (something like DoEvents
in Visual Basic) or with a timer instruction which regularly calls a
function I define?

Thanks
Marco
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Marco Terzuoli wrote:
Hi,
I am making a program which has got some GUI. I need a timer in it which
performs some kind of operations. What I am doing now is something like

while 1:
sleep(1)
do_stuff()

But this way I cannot interact with the GUI since the program is only run
within the while loop. Is there any way to solve the problem either with a
function that temporarily passes control to the OS (something like DoEvents
in Visual Basic) or with a timer instruction which regularly calls a
function I define?
One of your best solutions is to use a worker thread. What GUI toolkit
are you using? There are many examples available for most toolkits.

Most GUI's do support some form of message pushing like DoEvents, I
believe Tkinter's mainloop can be called with an integer value to
process a certain number of events, although this might be a bad memory
on my part.

Brian


Thanks
Marco


Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.