[pygtk] gtk main loop alternatives
Michael Hohn
mhhohn at lbl.gov
Tue Oct 30 02:46:49 WST 2007
Donn wrote:
> Hi,
> I want to try and draw a series of cairo shapes in a loop that does other
> stuff like:
>
> while True:
> canvas.draw()
> updateStuff()
> checkStuff()
>
> How do I fit this concept together with the gtk.main() that seems to stop
> there? Am I looking at some kind of timeout() command?
>
> \d
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
>
You can manually implement a nested event loop.
Using the simple function
def flush_events():
# Updates bounding boxes, among others.
while gtk.events_pending():
gtk.main_iteration()
your loop could be
while True:
draw()
flush_events()
as long as draw() does not block.
-- Mike
More information about the pygtk
mailing list