BoxSizer seems to fail at enforcing proportion constraints for me

So in the sample/demo I’m including, I create a panel with two lists and some buttons… then I add some items to the left-side list. Both lists have been Added to the sizer with proportion 1, and the buttons between the lists with proportion 0.

I cannot figure out why the two lists aren’t actually equal in proportion.

With the WIT I am able to get the size of the first list, use it to set the size of the second list, then Refresh/Layout the sizers and panels so the list and button sizes add up, and then I was able to use that width to manually set the size of the Dialog. So this really seems like the sizers aren’t doing their job at handling proportions. Am I calling something wrong?

testcustomdialog.py (4.23 KB)

Hi Nathan,

testcustomdialog.py (4.27 KB)

···

On 9/16/2014 19:44, Nathan McCorkle wrote:

So in the sample/demo I'm including, I create a panel with two lists and some buttons... then I add some items to the left-side list. Both lists have been Added to the sizer with proportion 1, and the buttons between the lists with proportion 0.

I cannot figure out why the two lists aren't actually equal in proportion.

It is because of the 'pins' you add to the left list.

One way of working around that is attached, i.e. use CallAfter to add the pins and use the RESIZE_BORDER style to all the user to adjust the size if necessary.

Werner

I cannot figure out why the two lists aren’t actually equal in proportion.

It is because of the ‘pins’ you add to the left list.

Hmm, why would that all-of-a-sudden cause the sizer ‘philosophy’ to change? If I tell it to have equal proportion, then shouldn’t it respect that constraint else be called broken?

One way of working around that is attached, i.e. use CallAfter to add

The dialog is quite small compared to what I expect it to be… without the CallAfter to addPins (calling addPins immediately) the left-side list looks to be the width I expect. The entries are not cut off. I then want the sizer constraint to do it’s job and make the right-side list the same width as the left-side (i.e. so their proportions of the Dialog are equal).

I expect the Dialog to grow a bit wider, rather than the lists be shrunken.

the pins and use the RESIZE_BORDER style to all the user to adjust the
size if necessary.

I thought the point of using a Dialog was that the user couldn’t do things like resize. In any case, I want the default behavior to be relatively easy on the eyes.

···

On Wednesday, September 17, 2014 12:04:13 AM UTC-7, werner wrote:

I am not the best one to explain but the way I understand it is that
‘proportion’ only kicks in after sizers considered minimum space for
a widget, and then what is left over to distribute is handed out to
each widget based on its proportion.
Werner

···

Hi Nathan,

  On 9/17/2014 18:36, Nathan McCorkle wrote:
    On Wednesday, September 17, 2014 12:04:13 AM UTC-7, werner

wrote:

      > I

cannot figure out why the two lists aren’t actually equal in
proportion.

      It is because of the 'pins' you add to the left list.
      Hmm, why would that all-of-a-sudden cause the sizer

‘philosophy’ to change? If I tell it to have equal proportion,
then shouldn’t it respect that constraint else be called
broken?

http://wiki.wxpython.org/UsingSizers
http://wxpython.org/Phoenix/docs/html/Sizer.html#Sizer.Add
http://www.wxpython.org/docs/api/wx.BoxSizer-class.html

Using my original code I added:

wx.CallAfter(mainVSizer.Fit, self)

and it worked as I expect!

Was helped by the comment/quoted text here:

https://groups.google.com/d/msg/wxpython-users/q2Gihbw0qtM/hfbQxZHB2vcJ

···

On Wednesday, September 17, 2014 9:48:14 AM UTC-7, werner wrote:

Hi Nathan,

  On 9/17/2014 18:36, Nathan McCorkle wrote:
    On Wednesday, September 17, 2014 12:04:13 AM UTC-7, werner > > wrote:
      > I

cannot figure out why the two lists aren’t actually equal in
proportion.

      It is because of the 'pins' you add to the left list.
      Hmm, why would that all-of-a-sudden cause the sizer

‘philosophy’ to change? If I tell it to have equal proportion,
then shouldn’t it respect that constraint else be called
broken?

I am not the best one to explain but the way I understand it is that

‘proportion’ only kicks in after sizers considered minimum space for
a widget, and then what is left over to distribute is handed out to
each widget based on its proportion.

[http://wiki.wxpython.org/UsingSizers](http://wiki.wxpython.org/UsingSizers)

[http://wxpython.org/Phoenix/docs/html/Sizer.html#Sizer.Add](http://wxpython.org/Phoenix/docs/html/Sizer.html#Sizer.Add)

[http://www.wxpython.org/docs/api/wx.BoxSizer-class.html](http://www.wxpython.org/docs/api/wx.BoxSizer-class.html)

...

Using my original code I added:
wx.CallAfter(mainVSizer.Fit, self)

and it worked as I expect!

Great, never used sizer.Fit that way, i.e. passing it the parent window to have it resize the window - have to remember that one!

Werner

···

On 9/17/2014 20:22, Nathan McCorkle wrote:

As it turns out, I didn’t even have to call that with wx.CallAfter, just mainVSizer.Fit(self) at the end of my Dialog init

···

On Wednesday, September 17, 2014 11:58:27 AM UTC-7, werner wrote:

Using my original code I added:

wx.CallAfter(mainVSizer.Fit, self)

and it worked as I expect!

Great, never used sizer.Fit that way, i.e. passing it the parent window
to have it resize the window - have to remember that one!