[pygtk] gtk.main in a thread

Dieter Verfaillie dieterv at optionexplicit.be
Fri Dec 16 03:33:16 WST 2011


On Thu, 15 Dec 2011 19:37:03 +0100, Marcin Szewczyk wrote:
> On Thu, Dec 15, 2011 at 03:08:10PM +0100, Dieter Verfaillie wrote:
>> 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.

You mean "Thread(target = gtk.main, name = "GTK thread")"?
If so, "target" is the callable object to be invoked by the run() 
method.
Whatever is executed by the run() method runs in in the new thread
you created, not the main thread.

mvg,
Dieter



More information about the pygtk mailing list