[pygtk] Pygtk app and hangs.
Seltzer
squabbit7 at gmail.com
Tue Oct 9 13:03:22 WST 2007
i use gtk.gdk.threads_init() as well,
and don't wrap the main loop in threads enter/leave,
all seems to work well...
hope it helps,
felix
On 9/23/07, John Stowers <john.stowers.lists at gmail.com> wrote:
>
> >
> > Q. Anything I missed, or any suggestions. Is there a
> > comprehensive list/scheme on how to write a MT pygtk
> > app?
> >
>
> After writing a few threaded pygtk programs [1][2] I have settled on
> one approach which I consistently use, I try not to mix the
> threads_enter and threads_leave with idle_add, I use the latter
> exclusively.
>
> I basically override gobject.emit() and always emit on the idle
> handler. Any limitations where you want to touch the GUI from other
> threads and feel you cannot use signals are usually representative of
> design omissions and I find they can usually be rectified by
> restructuring things into a more OO form and deriving from the code
> shown below [3].
>
> Anyway, good luck,
>
> John
>
> [1] http://www.conduit-project.org/
> [2]
> http://www.johnstowers.co.nz/blog/index.php/2007/03/12/threading-and-pygt=
k/
> [3]
>
> class IdleObject(gobject.GObject):
> __gsignals__ =3D {
> "foo" : (
> gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
> }
> def __init__(self, emitOnIdle=3DFalse):
> gobject.GObject.__init__(self)
> self.emitOnIdle =3D emitOnIdle
>
> def emit(self, *args):
> """
> Override the gobject signal emission so that signals
> can be emitted from the main loop on an idle handler
> """
> if self.emitOnIdle =3D=3D True:
> gobject.idle_add(gobject.GObject.emit,self,*args)
> else:
> gobject.GObject.emit(self,*args)
> _______________________________________________
> 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/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20071008/b458dcc9/at=
tachment.htm
More information about the pygtk
mailing list