[pygtk] some more problems in moving a widget

Johan Dahlin jdahlin at async.com.br
Thu Feb 16 19:21:03 WST 2006

> Traceback (most recent call last):
>   File "ellipse-move.py", line 73, in do_size_request
>     width, height = self._layout.get_size()
> AttributeError: 'PyGtkWidget' object has no attribute '_layout'
> TypeError: do_expose_event() takes exactly 3 arguments (2 given)

Two separate errors. The first one says that the _layout object is not 
In my example it's done in the constructor (should perhaps be in the 
realize mehtod).
So when copy/pasting code, make sure to do it properly

The second error means that you changed the function declaration,
do_* methods are different  from normal callbacks, they do not receive 
the target
object as the first argument, instead the target object is self, so 
instead of

def do_expose_event(self, window, event)

just do

def do_expose_event(self, event)

> i never faced this in the ellipse prototypes. There's another question 
> around the same, why is it that one can only add one widget object 
> onto a gtk drawing area ? i tried the following :
You can only add one widget per bin (a window is a bin subclass as the 
error message says).
To add more widgets you need to use a container, such as a box or a table.
This is covered by the tutorial which I suggest that you read.


More information about the pygtk mailing list