[pygtk] gtk.Builder & inherited widgets

Dieter Verfaillie dieterv at optionexplicit.be
Wed Dec 15 19:37:30 WST 2010


On 15/12/2010 00:09, Alessandro Dentella wrote:
> Hi Dieter,
> 
> On Tue, Dec 14, 2010 at 08:28:19PM +0100, Dieter Verfaillie wrote:
>> On 14/12/2010 17:41, Alessandro Dentella wrote:
>>> What am I doing wong?
>>
>> See the attachment. Got it working :)
> 
> If I understand correctly, what makes the difference, is that you're emitting
> the signal OUT of __init__. That works but does not explain why Test1 *can*
> emit from within the __init__.

That and the test class from your original example did not initialize
it's base class...

> In the real example, the signal is really emitted within __init__, and that
> have always worked in glade.

Are you sure? Changing the script to emit from __init__ seems to fail
for both libglade and gtkbuilder for me. Tested it both on mswindows
and linux with pygtk-2.22.0, pygobject-2.26.0, etc.
See the attached script, output here looks like:

manual test
========================================
instantiate Test1
__init__ Test1
my-signal1 has been emitted
instantiate Test2
__init__ Test2
__init__ Test1
my-signal1 has been emitted
my-signal2 has been emitted

libglade test
========================================
__init__ Test1
my-signal1 has been emitted
__init__ Test2
__init__ Test1
my-signal1 has been emitted
Traceback (most recent call last):
  File "test.py", line 103, in __init__
    self.emit('my-signal2')
TypeError: <Test2 object at 0x1595b70 (Test1 at 0xcea220)>: unknown
signal name: my-signal2

gtkbuilder test
========================================
instantiate Test1
__init__ Test1
my-signal1 has been emitted
instantiate Test2
__init__ Test2
__init__ Test1
my-signal1 has been emitted
Traceback (most recent call last):
  File "test.py", line 103, in __init__
    self.emit('my-signal2')
TypeError: <Test2 object at 0x1595d50 (Test1 at 0xcea310)>: unknown
signal name: my-signal2
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.py
URL: <http://www.daa.com.au/pipermail/pygtk/attachments/20101215/1f689711/attachment.ksh>


More information about the pygtk mailing list