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.szewc...@wodny.borg  <- remove b / usuĊ„ b
xmpp:wo...@ubuntu.pl                  xmpp:wo...@jabster.pl
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to