Updating GUI during long operation



Hey list,

I have a separate thread from the main loop that performs some long and
resource intensive operation. The GUI displays an animated GIF while
this process takes place via Gdk.PixbufAnimation. 

Sometimes the animation and the rest of the GUI is very slow to repaint
and respond to other event messages. What is the best way of giving the
message pipeline a breather every now and then from outside of the main
thread?

I was using GObject.idle_add(self._updateGUI, ...) within the worker
thread to specify a function to be called regularly that could provide
some other GUI related update tasks, including the following within
it...

        # Pump the Gtk+ event handler...
        while Gtk.events_pending():
            Gtk.main_iteration()

However, my application will crash if I do this with a stack overflow
within updateGUI. I'm assuming that since idle_add posted the message to
call the updateGUI callback, when the callback is invoked and tries to
pump the message pipeline, the method is invoked again because it still
hasn't cleared itself from the queue.

I could have tried this aforementioned event pump from outside the
updateGUI callback and done it from within the worker thread, but I
didn't know if that was thread safe to do.

-- 
Kip Warner -- Software Engineer
OpenPGP encrypted/signed mail preferred
http://www.thevertigo.com


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]