1.

When Creating A New Signal, How Do I Define One Of The Signal Arguments As Python Data?

Answer»

When you add your signal using gobject.signal_new(), use gobject.TYPE_PYOBJECT as the type for the ARGUMENT being PASSED in:

gobject.signal_new("signal", ClassName,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))

And then you can emit the signal with PYTHON OBJECTS:

mydict = {}
mydict["foo"] = "bar"
class_instance.emit("signal", mydict)

And get them when you connect on the other SIDE:

def signal_cb(instance, mydict):
print mydict["foo"]

class_instance.connect("signal", signal_cb)

When you add your signal using gobject.signal_new(), use gobject.TYPE_PYOBJECT as the type for the argument being passed in:

gobject.signal_new("signal", ClassName,
gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
(gobject.TYPE_PYOBJECT,))

And then you can emit the signal with Python objects:

mydict = {}
mydict["foo"] = "bar"
class_instance.emit("signal", mydict)

And get them when you connect on the other side:

def signal_cb(instance, mydict):
print mydict["foo"]

class_instance.connect("signal", signal_cb)



Discussion

No Comment Found