On Sat, Feb 11, 2006 at 10:04:33PM +0100, Jarek Zgoda wrote:
> I'd like to emit signal from GObject descendant created in separate
> thread and to respond in a callback in main thread. Do I need to do
> something magic, as currently my callbacks simply don't fire? I have
> threading enabled in an application entry point module (threads_init()
> et caetera).

If I understand correctly, you want the possibility that one threads
emits a signal to an object and that this signal will be treated
in the same way as if it came from a mouse click or things like that.

Yes it is possible, but yes it requires some magic.

This is how I do it:

import gtk
import gobject as gob
import gtk.gdk as gdk

def Emit(obj, *args):

    def Do_Emit(obj, sig, *args):
        gdk.threads_enter()
        obj.emit(sig, *args)
        gdk.threads_leave()
        return False
    #end Do_Emit

    gob.idle_add(Do_Emit, obj, *args, **{"priority" : gob.PRIORITY_HIGH})
#end Emit

To be used as follows:

Emit(obj, signal, args)

-- 
Antoon Pardon
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to