开发者

How to create a gsignal without parameters in pygtk

开发者 https://www.devze.com 2023-02-22 08:26 出处:网络
The pygtk signal documentation is pretty clear about signals creation, but I could not create a signal that doesn\'t take parameters.

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__ 开发者_StackOverflow= {
      "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.


Just use an empty tuple as the third argument.

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

精彩评论

暂无评论...
验证码 换一张
取 消