[pygtk] How to place widgets on a grid?

Arjan Molenaar gaphor at gmail.com
Wed Mar 10 01:49:11 WST 2010


Hi,

On 6 Mar 2010, at 19:26, Martin Drautzburg wrote:

> Hello all,
> 
> I've been struggeling with the following problem: I want to have a grid in the 
> background and I want to put Buttons (or other Widgets) on the  Grid.
> 
> I tried painting the grid using a DrawingArea. Which works. But I don't know 
> how to place other widgets on top. 
> 
> I tried using a gtk.Layout. This allows me to e.g. place two Button on the 
> screen so they overlap. The stacking order seems to be "last added widgets on 
> top". But this does not seem to work with the drawing area. The drawing area 
> is ALWAYS on top and hides my other widgets.
> 
> If you tell me, that this shouldn't be, I'll go and look for glitches in my 
> code, but I suspect a more fundamental problem.

You should be able to draw in the GtkLayout directly, by overriding the expose event (do_expose_event(self, event)).
This has the same abilities as using the DrawingArea. If you call the parent class (the Layout) last. Take into account that a Layout is scrollable, whereas DrawingArea is not.

Regards,

Arjan


More information about the pygtk mailing list