Can anyone enlighten me, please, how do I emit signal in an instance of one
class and receive it in an instance of another class, both GObject descendants?
In all examples I found to date, signals was emitted and received in the same
class. Is it possible at all?
I narrowed my problem to attached code and I am really stuck with this problem.
Cheers
Jarek Zgoda
# -*- coding: utf-8 -*-
import time
import gobject
class Emitter(gobject.GObject):
__gsignals__ = {
'sig-1': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
}
def __init__(self):
gobject.GObject.__init__(self)
def emitSignal(self):
self.emit('sig-1')
class Receiver(gobject.GObject):
def __init__(self):
gobject.GObject.__init__(self)
self.connect('sig-1', self.onFirst)
def onFirst(self):
print 'received signal sig-1'
gobject.type_register(Receiver)
gobject.signal_new(
'sig-1',
Receiver,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
()
)
if __name__ == '__main__':
e = Emitter()
r = Receiver()
print 'emitter emits sig-1'
e.emitSignal()
time.sleep(3)
print 'after 3 seconds emitter once again emits sig-1'
e.emitSignal()
_______________________________________________
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/