How to make control fill most of box sizer?

Hey list,
I've been messing with box sizers this morning, and much to my shock,
my window is actually laid out how I want it! I have two listCtrl
items, one on the left and one on the right, each with three buttons
beneath it. I plan to add a label above each list as well. To do this,
I have a mainSizer, which is horizontal; a vertical sizer for each
side of my window; and a horizontal sizer for each set of buttons. I
add my buttons to the proper horizontal sizers, then add my listCtrl
object and one of the buttons sizers to the proper vertical sizer,
then add both of those to the mainSizer and set that using
self.SetSizer(mainSizer) (I'm subclassing a panel).

Here's my only problem: my lists are vertically tiny. They are plenty
wide enough, but they are both only an inch or so tall. I want them to
fill most of the space in their respective sizers, so my users can see
a lot of data at once. I have the proportions of everything set to 0,
and the proportions of these two listCtrl objects set to 1. What do I
need to do to make these two lists expand vertically? I'll paste my
code below in case that helps. Again, "self" is a subclass of
wx.Panel, which is added to a notebook in a frame elsewhere in the
GUIManager module of the app. Thanks in advance.

  self.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
  self.tablesControlsSizer = wx.BoxSizer(wx.VERTICAL)
  self.recordsControlsSizer = wx.BoxSizer(wx.VERTICAL)
  self.tablesButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)
  self.recordsButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)

  self.tablesButtonsSizer.Add(self.add_button, 0, wx.ALL|wx.ALIGN_LEFT, 10)
  self.tablesButtonsSizer.Add(self.edit_button, 0, wx.ALL|wx.ALIGN_CENTER, 10)
  self.tablesButtonsSizer.Add(self.delete_button, 0, wx.ALL|wx.ALIGN_RIGHT, 10)

  self.recordsButtonsSizer.Add(self.addRecord_button, 0,
wx.ALL|wx.ALIGN_LEFT, 10)
  self.recordsButtonsSizer.Add(self.editRecord_button, 0,
wx.ALL|wx.ALIGN_CENTER, 10)
  self.recordsButtonsSizer.Add(self.deleteRecord_button, 0,
wx.ALL|wx.ALIGN_RIGHT, 10)

  self.tablesControlsSizer.Add(self.items_listControl, 1, wx.EXPAND)
  self.tablesControlsSizer.Add(self.tablesButtonsSizer, 0, wx.ALIGN_BOTTOM)

  self.recordsControlsSizer.Add(self.records_listControl, 1, wx.EXPAND)
  self.recordsControlsSizer.Add(self.recordsButtonsSizer)

  self.mainSizer.Add(self.tablesControlsSizer, 1, wx.RIGHT, 15)
  self.mainSizer.Add(self.recordsControlsSizer, 1, wx.LEFT, 15)

  if self.useHighContrast:
   self.items_listControl.SetBackgroundColour("blue")
   self.records_listControl.SetBackgroundColour("green")
   self.SetBackgroundColour("#000000")
  #end if

  self.SetAutoLayout(True)
  self.SetSizer(self.mainSizer)

  self.Layout()

Hi,
unfortunately, I can't find the exact problem in the code segments of
your gui setup - generally, in my limited experience, in such cases,
there may be some problems in settings of the "parent" sizers, which
don't allow the expansion as needed.

I recommend using WIT - Widget Inspection Tool for such gui debugging
(it is e.g. possible to graphically highlight the respective elements
or review the parameters):

http://wiki.wxpython.org/Widget Inspection Tool

or for wxpython Phoenix:
http://wxpython.org/Phoenix/docs/html/lib.mixins.inspection.html

Hopefully, you will be able to track the problem in your complete
(runnable) code.

hth,
   vbr

···

2016-02-03 14:10 GMT+01:00 Alex Hall <ahall@autodist.com>:

Hey list,
I've been messing with box sizers this morning, and much to my shock,
my window is actually laid out how I want it! I have two listCtrl
items, one on the left and one on the right, each with three buttons
beneath it. I plan to add a label above each list as well. To do this,
I have a mainSizer, which is horizontal; a vertical sizer for each
side of my window; and a horizontal sizer for each set of buttons. I
add my buttons to the proper horizontal sizers, then add my listCtrl
object and one of the buttons sizers to the proper vertical sizer,
then add both of those to the mainSizer and set that using
self.SetSizer(mainSizer) (I'm subclassing a panel).

Here's my only problem: my lists are vertically tiny. They are plenty
wide enough, but they are both only an inch or so tall. I want them to
fill most of the space in their respective sizers, so my users can see
a lot of data at once. I have the proportions of everything set to 0,
and the proportions of these two listCtrl objects set to 1. What do I
need to do to make these two lists expand vertically? I'll paste my
code below in case that helps. Again, "self" is a subclass of
wx.Panel, which is added to a notebook in a frame elsewhere in the
GUIManager module of the app. Thanks in advance.

  self.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
  self.tablesControlsSizer = wx.BoxSizer(wx.VERTICAL)
  self.recordsControlsSizer = wx.BoxSizer(wx.VERTICAL)
  self.tablesButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)
  self.recordsButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)

  self.tablesButtonsSizer.Add(self.add_button, 0, wx.ALL|wx.ALIGN_LEFT, 10)
  self.tablesButtonsSizer.Add(self.edit_button, 0, wx.ALL|wx.ALIGN_CENTER, 10)
  self.tablesButtonsSizer.Add(self.delete_button, 0, wx.ALL|wx.ALIGN_RIGHT, 10)

  self.recordsButtonsSizer.Add(self.addRecord_button, 0,
wx.ALL|wx.ALIGN_LEFT, 10)
  self.recordsButtonsSizer.Add(self.editRecord_button, 0,
wx.ALL|wx.ALIGN_CENTER, 10)
  self.recordsButtonsSizer.Add(self.deleteRecord_button, 0,
wx.ALL|wx.ALIGN_RIGHT, 10)

  self.tablesControlsSizer.Add(self.items_listControl, 1, wx.EXPAND)
  self.tablesControlsSizer.Add(self.tablesButtonsSizer, 0, wx.ALIGN_BOTTOM)

  self.recordsControlsSizer.Add(self.records_listControl, 1, wx.EXPAND)
  self.recordsControlsSizer.Add(self.recordsButtonsSizer)

  self.mainSizer.Add(self.tablesControlsSizer, 1, wx.RIGHT, 15)
  self.mainSizer.Add(self.recordsControlsSizer, 1, wx.LEFT, 15)

  if self.useHighContrast:
   self.items_listControl.SetBackgroundColour("blue")
   self.records_listControl.SetBackgroundColour("green")
   self.SetBackgroundColour("#000000")
  #end if

  self.SetAutoLayout(True)
  self.SetSizer(self.mainSizer)

  self.Layout()

--

Thank you! You mentioned that parent sizers may not be set correctly,
which made me look at where I add my second-level sizers to the main
one. Once I gave those two wx.EXPAND, suddenly my lists were as big as
I'd hoped. Remember to let your sizers expand in parent sizers, not
just the controls, is the lesson here. :slight_smile:

···

On 2/3/16, Vlastimil Brom <vlastimil.brom@gmail.com> wrote:

2016-02-03 14:10 GMT+01:00 Alex Hall <ahall@autodist.com>:

Hey list,
I've been messing with box sizers this morning, and much to my shock,
my window is actually laid out how I want it! I have two listCtrl
items, one on the left and one on the right, each with three buttons
beneath it. I plan to add a label above each list as well. To do this,
I have a mainSizer, which is horizontal; a vertical sizer for each
side of my window; and a horizontal sizer for each set of buttons. I
add my buttons to the proper horizontal sizers, then add my listCtrl
object and one of the buttons sizers to the proper vertical sizer,
then add both of those to the mainSizer and set that using
self.SetSizer(mainSizer) (I'm subclassing a panel).

Here's my only problem: my lists are vertically tiny. They are plenty
wide enough, but they are both only an inch or so tall. I want them to
fill most of the space in their respective sizers, so my users can see
a lot of data at once. I have the proportions of everything set to 0,
and the proportions of these two listCtrl objects set to 1. What do I
need to do to make these two lists expand vertically? I'll paste my
code below in case that helps. Again, "self" is a subclass of
wx.Panel, which is added to a notebook in a frame elsewhere in the
GUIManager module of the app. Thanks in advance.

  self.mainSizer = wx.BoxSizer(wx.HORIZONTAL)
  self.tablesControlsSizer = wx.BoxSizer(wx.VERTICAL)
  self.recordsControlsSizer = wx.BoxSizer(wx.VERTICAL)
  self.tablesButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)
  self.recordsButtonsSizer = wx.BoxSizer(wx.HORIZONTAL)

  self.tablesButtonsSizer.Add(self.add_button, 0, wx.ALL|wx.ALIGN_LEFT,
10)
  self.tablesButtonsSizer.Add(self.edit_button, 0, wx.ALL|wx.ALIGN_CENTER,
10)
  self.tablesButtonsSizer.Add(self.delete_button, 0,
wx.ALL|wx.ALIGN_RIGHT, 10)

  self.recordsButtonsSizer.Add(self.addRecord_button, 0,
wx.ALL|wx.ALIGN_LEFT, 10)
  self.recordsButtonsSizer.Add(self.editRecord_button, 0,
wx.ALL|wx.ALIGN_CENTER, 10)
  self.recordsButtonsSizer.Add(self.deleteRecord_button, 0,
wx.ALL|wx.ALIGN_RIGHT, 10)

  self.tablesControlsSizer.Add(self.items_listControl, 1, wx.EXPAND)
  self.tablesControlsSizer.Add(self.tablesButtonsSizer, 0,
wx.ALIGN_BOTTOM)

  self.recordsControlsSizer.Add(self.records_listControl, 1, wx.EXPAND)
  self.recordsControlsSizer.Add(self.recordsButtonsSizer)

  self.mainSizer.Add(self.tablesControlsSizer, 1, wx.RIGHT, 15)
  self.mainSizer.Add(self.recordsControlsSizer, 1, wx.LEFT, 15)

  if self.useHighContrast:
   self.items_listControl.SetBackgroundColour("blue")
   self.records_listControl.SetBackgroundColour("green")
   self.SetBackgroundColour("#000000")
  #end if

  self.SetAutoLayout(True)
  self.SetSizer(self.mainSizer)

  self.Layout()

--

Hi,
unfortunately, I can't find the exact problem in the code segments of
your gui setup - generally, in my limited experience, in such cases,
there may be some problems in settings of the "parent" sizers, which
don't allow the expansion as needed.

I recommend using WIT - Widget Inspection Tool for such gui debugging
(it is e.g. possible to graphically highlight the respective elements
or review the parameters):

http://wiki.wxpython.org/Widget Inspection Tool

or for wxpython Phoenix:
http://wxpython.org/Phoenix/docs/html/lib.mixins.inspection.html

Hopefully, you will be able to track the problem in your complete
(runnable) code.

hth,
   vbr

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

For anyone following, this now works:
  self.mainSizer.Add(self.tablesControlsSizer, 1, wx.RIGHT|wx.EXPAND, 15)
  self.mainSizer.Add(self.recordsControlsSizer, 1, wx.LEFT|wx.EXPAND, 15)