[pygtk] Threads in PyGTK: keep typing while ping-ing

Graham Whelan gawhelan at gmail.com
Tue Feb 17 22:20:06 WST 2009


2009/2/17 John Stowers <john.stowers.lists at gmail.com>
>
> But remember, the callback will be executed in the context of the
> running thread, which means if you intend to touch the gui from this
> thread you will need to get the gtk lock.
>
> That is why I always recommend [1] doing communication from the thread
> to the main application using gobject signals emitted in an idle
> handler. This way it allows you to retain a normal gobject signal based
> design for your app.
>

Yes, my normal way of doing this was to emit gobject signals from the
worker thread, but I never realized that the signal handlers are
called from the same thread as the emitted the signal. I naively
assumed the signals were passed to the gtk.main() loop.

Thanks for informing me about this. Now I have to go apply that
gobject.idle_add() trick in a few places.

Graham


More information about the pygtk mailing list