Hi,
in the attached example I have a very simple xml definition (a button in a
Window).
The Button is not really a gtk.Button it's defined with its own signal:
class Test(gtk.Button):
__gtype_name__ = 'Test'
__gsignals__ = {
'my-signal' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
()
),
}
def __init__(self):
self.emit('my-signal')
A second Test is derived from this one. The example fails when using the
second example and works correctly with the first one.
What am I doing wong?
It seems there's no way to make it see the signal defined in the derived
Test2 class, but I don't see anything special. Even Test inheritates from
other widgets (gtk.Button).
Any hints?
thanks
sandro
*:-)
--
Sandro Dentella *:-)
http://www.reteisi.org Soluzioni libere per le scuole
http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy
#!/usr/bin/python
"""
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-requires pythonplugin 0.0 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
<property name="visible">True</property>
<child>
<object class="%s" id="test1">
<property name="label" translatable="yes">Stop</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
</child>
</object>
</interface>
"""
# call this script as 'python mytest.py Test' and it just works
# call this script as 'python mytest.py Test2' and it complains:
#
# Traceback (most recent call last):
# File "mytest.py", line 58, in __init__
# self.emit('my-signal2')
# TypeError: <Test2 object at 0x920f144 (Test at 0x8fdc480)>: unknown signal name: my-signal2
import gobject
import gtk
class Test(gtk.Button):
__gtype_name__ = 'Test'
__gsignals__ = {
'my-signal' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
()
),
}
def __init__(self):
self.emit('my-signal')
class Test2(Test):
__gtype_name__ = 'Test2'
__gsignals__ = {
'my-signal2' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
()
),
}
def __init__(self):
Test.__init__(self)
self.emit('my-signal2')
if __name__ == '__main__':
import gtk
import sys
b = gtk.Builder()
xml = __doc__ % (len(sys.argv) > 1 and sys.argv[1] or 'Test')
b.add_from_string(xml, len(xml))
b.get_object('test1').connect('clicked', gtk.main_quit)
try:
gtk.main()
except KeyboardInterrupt:
sys.exit()
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/