[wxPython] strange sizer behavior

[wxPython 2.2.2, Python 1.5.2, Win2K]

Hi All,

The attached code either demonstrates some strangeness in the behavior of objects added to a sizer or a fundamental misunderstanding on my part. I figure that both are equally likely, so I'm looking for guidance.

On my machine, large values of nTics (8 is enough to show the problem) in these nested sizers results in the second wxTextCtrl getting squashed vertically. The wxStaticText elements are unaffected. This seems wrong to me.

Further information:
1) If there is only one wxTextCtrl, it is not affected by this problem.
2) Setting nTics to 20 results in the first wxTextCtrl being EXPANDED while the other gets squashed.

Can anyone straighten me out?

Thanks!
-greg

SizerMadness.py (1.47 KB)

The attached code either demonstrates some strangeness in the behavior of
objects added to a sizer or a fundamental misunderstanding on my part. I
figure that both are equally likely, so I'm looking for guidance.

Do you really want the controls to resize vertically? If not then change
the second parameter in all the bigSizer.Add(...) calls to zero. After
doing that there is no oddity from my perspective.

For box sizers, the second parameter to Add allows the item to stretch in
the direction of the sizer (horizontally for wxHORIZONAL flag, etc.) if
greater than zero. If there is more than one item with a non zero value
they the values act as a proportion indicator. For example if you have 8
fixed size items with a zero in the second spot, and one item with a 1 and
one item with a 2, then the free space left over after laying out the fixed
size items is divided between the two stratchable items and one gets a
double portion than the other. As you've seen the proportional calcualtion
has a few quirks when there is more than a few stretchable items, basically
since you can't have a fractional pixel it just gives up and gives all the
remainder to one item.

The wxEXPAND flag added to the third parameter to a box sizer Add() means
that the item is allowed to stretch in the alternate direction, i.e., if
it's a wxHORIZONTAL box sizer, then the item will be resized vertically to
fill the space given to it.

P.S. If you're trying to line up labels and controls then the
wxFlexGridSizer works real good. No need to use nested boxes at all.

P.P.S Changing the background colour of some of the items is an easy way to
help diagnose sizer problems.

P.P.P.S. Robert's wxDesigner product makes building sizer based panels and
dialogs pretty easy.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Thanks for the quick response Robin.

Do you really want the controls to resize vertically? If not then change
the second parameter in all the bigSizer.Add(...) calls to zero. After
doing that there is no oddity from my perspective.

This did indeed clear things up.

P.S. If you're trying to line up labels and controls then the
wxFlexGridSizer works real good. No need to use nested boxes at all.

That was actually just a simplification of the actual code. It turns out to be easier to use nested boxes for my particular application (at least it seems to be so far).

P.P.S Changing the background colour of some of the items is an easy way to
help diagnose sizer problems.

Stupidly, though I've done this in the past, it didn't occur to me this time. Thanks for the pointer though.

Thanks again for the help,
-greg

···

At 07:45 PM 11/27/2000, you wrote:

----
greg Landrum (greglandrum@earthlink.net)
Software Carpenter/Computational Chemist

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users