Search code examples
pythonpygtksignalsgobjectpygobject

How to create a gsignal without parameters in pygtk


The pygtk signal documentation is pretty clear about signals creation, but I could not create a signal that doesn't take parameters.

What I want is to define (like in the example):

class MyGObjectClass(gobject.GObject):
    __gsignals__ = {
      "some-signal": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE),
    }

and then call:

self.emit('some-signal') # not passing any arguments

Currently I can't do this, since the third parameter for gsignal_new is required, and can't be None.


Solution

  • Just use an empty tuple as the third argument.

    __gsignals__ = {
      "some-signal": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()),
    }