Using the Gtk 2.0 API, I have a subclass of GtkEntry to which I've attached
three new signals: history-prev, history-next, and history-menu:
class _HEntry(gtk.Entry):
def __init__(self, *args):
gtk.Entry.__init__(self, *args)
self.set_name("_history_")
gobject.signal_new("history-prev", _HEntry,
gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION,
gobject.TYPE_NONE, ())
gobject.signal_new("history-next", _HEntry,
gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION,
gobject.TYPE_NONE, ())
gobject.signal_new("history-menu", _HEntry,
gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION,
gobject.TYPE_NONE, ())
I want to add the same signals to a subclass of GtkSpinButton:
class _HSpinButton(gtk.SpinButton):
def __init__(self, *args):
gtk.SpinButton.__init__(self, *args)
self.set_name("_history_")
gobject.signal_new("history-prev", _HSpinButton,
gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION,
gobject.TYPE_NONE, ())
gobject.signal_new("history-next", _HSpinButton,
gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION,
gobject.TYPE_NONE, ())
gobject.signal_new("history-menu", _HSpinButton,
gobject.SIGNAL_RUN_LAST|gobject.SIGNAL_ACTION,
gobject.TYPE_NONE, ())
When I try this, the signals seem to be defined for my GtkEntry subclass
just fine, but I get a Gtk warning and Python RuntimeError exception when
trying to attach the signals to the GtkSpinButton subclass:
History.py (pid:18736): GRuntime-WARNING **: gsignal.c:1147:g_signal_newv():
signal "history_prev" already exists in the `GtkEntry' class ancestry
Traceback (most recent call last):
...
File "/home/skip/src/tttech/projects/SW/lib/python/TGW/Spinner.py", line 19, in ?
gobject.TYPE_NONE, ())
RuntimeError: could not create signal
This is a bit frustrating. I thought the restriction on signal names was
that a direct ancestor of the class to which I was adding a signal couldn't
already be using this signal name. It seems to me that I need to add these
three signals rather high up in the widget hierarchy, which unfortunately
will pollute a lot of widgets that have no use for them with these signals.
Is there an alternative?
Thx,
Skip
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk