Sizer misunderstanding

I thought I was pretty studly with sizers, but I must have some kind of
misunderstanding. I know I should extract a small, runnable example,
and I will do that tonight, but first I'd like to describe what I have
and what I see.

I have a frame. The frame contains a wx.BoxSizer. The BoxSizer
contains two panels (OK, a panel and a grid, but the effect is the
same), both created with wx.EXPAND. I can see that the panels expand to
take up the entire frame, as I expected. I know that because I can
change the background color on the panel and see it change.

One of the panels contains a wx.GridBagSizer with 5 columns and 12 rows,
most of the cells of which contain static text and text controls. All
of the text controls are created with wx.EXPAND. The GridBagSizer is
"the" sizer for the panel.

Here's the issue. I expected that the cells in the grid bag sizer would
expand horizontally to fill the panel, but that's not happening. The
cells are the size they are, and there is a chunk of empty space to the
right. Have I missed some step? Is there a way for me to say "this
sizer should fully occupy its parent"?

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

Here's the issue. I expected that the cells in the grid bag sizer would
expand horizontally to fill the panel, but that's not happening. The
cells are the size they are, and there is a chunk of empty space to the
right. Have I missed some step? Is there a way for me to say "this
sizer should fully occupy its parent"?

It might be that wx.GridBagSizer is a little beast :wink: . I have never
used it, but does anything change if you do something like (not
tested, please triple-check it):

yourPanel = wx.Panel(self)
panelSizer = wx.BoxSizer(wx.HORIZONTAL)
yourPanel.SetSizer(panelSizer)

GBSizer = wx.GridBagSizer()

# Add your controls to wx.GridBagSizer

panelSizer.Add(GBSizer, 1, wx.EXPAND)
panelSizer.Layout()

?

HTH.

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

Have you tried to set a growable row or column? If not which column or
row should get the extra space available to the grid.

use something like grid.AddGrowableCol(colnr, stretching) where
stretching is the proportion as in normal sizers and is optional.

Hope this helps,

Thanks,

···

Am Dienstag, den 06.02.2007, 11:42 -0800 schrieb Tim Roberts:

Here's the issue. I expected that the cells in the grid bag sizer
would
expand horizontally to fill the panel, but that's not happening. The
cells are the size they are, and there is a chunk of empty space to
the
right. Have I missed some step? Is there a way for me to say "this
sizer should fully occupy its parent"?

--
BYTEWISE Software GmbH Tel +43 (5577) 89877-0
i.A. Johannes Vetter Fax +43 (5577) 89877-66
A-6890 Lustenau, Enga 2 http://www.bytewise.at
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Individuelle Datenbanklösungen für GNU/Linux, Windows und
Mac OSX: BYTEWISE Software GmbH - Unsere Leistungen - Datenbanklösungen

Tim Roberts wrote:

Here's the issue. I expected that the cells in the grid bag sizer would
expand horizontally to fill the panel, but that's not happening. The
cells are the size they are, and there is a chunk of empty space to the
right. Have I missed some step? Is there a way for me to say "this
sizer should fully occupy its parent"?

The EXPAND flag basically means that the item should fill the space allotted to it, but it doesn't have any affect on changing how the sizer behaves outside of that space. So as mentioned by others you need to tell the sizer which rows/cols that you want to be growable. Then when the sizer is given more space than it needs for the min size it divides up that extra space among the growable rows/cols.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!