[pygtk] gtk.main in a thread
Marcin Szewczyk
pygtk-mailinglist at wodny.org
Fri Dec 16 02:37:03 WST 2011
On Thu, Dec 15, 2011 at 03:08:10PM +0100, Dieter Verfaillie wrote:
> On Thu, 15 Dec 2011 14:38:37 +0100, Antoon Pardon wrote:
> >def startgtk(func, gtkthread = False):
> > if gtkthread:
> > thrd = Thread(target = gtk.main, name = "GTK thread")
> > thrd.deamon = True
> > thrd.start()
> > func()
> > else:
> > thrd = Thread(target = func, name = "Canvas thread")
> > thrd.deamon = True
> > thrd.start()
> > gtk.main()
> >
> >Calling this with gtkthread = False, doesn't pose a problem
> >but calling it with gtkthread = True makes it block on
> >one computer.
>
> Looking at GLib docs [2] we learn that: "... A GMainContext can only
> be running in a single thread, ...". Looks to me that what you are
> trying to do is not possible?
If I understand the code above correctly, gtk.main() is still used in a
single thread, just not the main one. So I can't agree the quoted
documentation explicitly forbids that.
Still, one can observe problems running gtk.main() outside the main
thread. I've asked a similar question some time ago.
I think that constraint should be mentioned in the pygtk documentation.
I've done some tests. If anyone is interested, they're in a repo:
https://bitbucket.org/wodny/pygtk-threads
--
Marcin Szewczyk http://wodny.org
mailto:Marcin.Szewczyk at wodny.borg <- remove b / usuń b
xmpp:wodny at ubuntu.pl xmpp:wodny at jabster.pl
More information about the pygtk
mailing list