How do I create a new signal in pygtk
Asked Answered
B

3

7

I've created a python object, but I want to send signals on it. I made it inherit from gobject.GObject, but there doesn't seem to be any way to create a new signal on my object.

Berkowitz answered 15/9, 2008 at 20:41 Comment(0)
V
11

You can also define signals inside the class definition:

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

The contents of the tuple are the the same as the three last arguments to gobject.signal_new.

Villagomez answered 15/9, 2008 at 22:52 Comment(0)
O
4

Here is how:

import gobject

class MyGObjectClass(gobject.GObject):
    ...

gobject.signal_new("signal-name", MyGObjectClass, gobject.SIGNAL_RUN_FIRST,
    None, (str, int))

Where the second to last argument is the return type and the last argument is a tuple of argument types.

Octavla answered 15/9, 2008 at 20:57 Comment(0)
P
2

If you use kiwi available here you can just do:

from kiwi.utils import gsignal

class MyObject(gobject.GObject):
    gsignal('signal-name')
Paddie answered 24/9, 2008 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.