2 grids in sizer ?

32 views
Skip to first unread message

Karsten Hilbert

unread,
Nov 12, 2012, 1:53:34 PM11/12/12
to wxp-users
Hi,

maybe someone can already hint me in the right direction
from the attached screenshots.

I've got a panel which contains (among other things) two
grids atop each other inside a vertical sizer. This sizer is
set to proportion=1 inside the (also vertical) parent sizer
such as to eat up all the space left over by other widgets
(those being propertion=0) inside the parent sizer. The top
grid is set to proportion=1 and the bottom grid is
proportion=2 inside their sizer.

The result can be seen in screenshot 2.

While this is acceptable I would like to see the top grid
occupying as much space as is needed to display all grid
rows and the bottom grid occupying "the rest" of the
available space.

This sounds like setting the top grid to proportion=0 and
the bottom grid to proportion=1 inside their sizer. This,
however, results in the top grid being of height=1pixel as
can be seen in screenshot 4 (where the pointer is at). Most
likely this results from MinSize being (1,1) as can be seen
in the screenshot of the inspector.

Can anyone point me in the right direction ?

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
screenshot_002.png
screenshot_004.png
screenshot_003.png

Robin Dunn

unread,
Nov 12, 2012, 3:49:39 PM11/12/12
to wxpytho...@googlegroups.com
On 11/12/12 10:53 AM, Karsten Hilbert wrote:

> This sounds like setting the top grid to proportion=0 and
> the bottom grid to proportion=1 inside their sizer. This,
> however, results in the top grid being of height=1pixel as
> can be seen in screenshot 4 (where the pointer is at). Most
> likely this results from MinSize being (1,1) as can be seen
> in the screenshot of the inspector.

Correct. If the minsize is set it will override any best size
calculations that the grid is doing for itself when the sizer calculates
the layout. What happens if you don't set the grid's minsize?


--
Robin Dunn
Software Craftsman
http://wxPython.org

Karsten Hilbert

unread,
Nov 12, 2012, 4:20:56 PM11/12/12
to wxpytho...@googlegroups.com
The funny thing is: I never do.

Attached find the (wxGlade generated) code which I am
subclassing in my application.

That cMeasurementsGrid class is a child of wx.grid.Grid and
also never sets a MinSize.

It seems the initial size is set to (1, 1) by wxGlade -
which is sensible as the grids are empty at that time.
wxgMeasurementsPnl.py

Robin Dunn

unread,
Nov 13, 2012, 1:26:01 PM11/13/12
to wxpytho...@googlegroups.com
On 11/12/12 1:20 PM, Karsten Hilbert wrote:
>
> It seems the initial size is set to (1, 1) by wxGlade -
> which is sensible as the grids are empty at that time.

More likely it is because grids typically contain more columns or rows
than can comfortably fit within another window, and so the default best
size calculation will try to make them too big. The min size overrides
that best size calc. You can call their SetMinSize method passing
wx.DefaultSize to reset that, or you can specify some size other than
(1,1) if you want them to have a more reasonable fixed minsize.

Karsten Hilbert

unread,
Nov 14, 2012, 5:45:05 PM11/14/12
to wxpytho...@googlegroups.com
On Tue, Nov 13, 2012 at 10:26:01AM -0800, Robin Dunn wrote:

> >It seems the initial size is set to (1, 1) by wxGlade -
> >which is sensible as the grids are empty at that time.
>
> More likely it is because grids typically contain more columns or
> rows than can comfortably fit within another window, and so the
> default best size calculation will try to make them too big. The min
> size overrides that best size calc. You can call their SetMinSize
> method passing wx.DefaultSize to reset that,

That helped :-)

Thanks,
Reply all
Reply to author
Forward
0 new messages