Defining custom GObject signals with itself as an argument




Hi,

I am trying to create a GObject subclass in Python3 that has instances of the class itself as one of the signal's arguments. For example:

> class Example(GObject):
> __gsignals__ = { 'eg': (Object.SIGNAL_RUN_FIRST, None, (Example,)) }

This common signal parameter idiom (you see it in GTK+ signals all the time) results in a TypeError being thrown when the module is loaded, since the class definition is not yet completely parsed (and hence Example is not available in locals()) when parsing the __gsignals__ value.

Further, this doesn't seem to work:

> class Example(GObject): pass
> Example.__gsignals__['eg'] = (Object.SIGNAL_RUN_FIRST, None, (Example,))

That leads to a TypeError("unknown signal name: eg") being thrown when attempting to connect a signal handler later on.

Is there a workaround for this?

Thanks,
//Mike

--
⊨ Michael Gratton, Percept Wrangler.
⚙ <http://mjog.vee.net/>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]