im using GridBagSizer for my UI Layout. Now im facing following problem.
the grid im using has 4 rows and 12 columns. on the second row (row 1) i ad a UltimateListCtrl and i want it to to grow if the window is resized vertically or horizontally.
ulc_style = ULC.ULC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT
self.list = ulc = ULC.UltimateListCtrl(self.panel, agwStyle=ulc_style)
self.sizer_grid = grid = wx.GridBagSizer(5,5)
grid.Add(self.list, (1,0), (1,12), flag=wx.EXPAND)
I use the following function to make the columns growable and also set row 1 to be growable.
for i in range(13):
grid.AddGrowableCol(i)
grid.AddGrowableRow(1)
I can resize the window horzizontally fine and alle elements resize with it but vertically the list stays where it is.
If i add size parameters to the ListCtrl the row will expand to the size i entered, and even expand further horizontally but vertically its still fixed to that size and wont adjust to the window size.
grid.AddGrowableRow(1)
Doesnt seem to do anything, when i remove it, the ui still looks the same. Im new to python and wxpython so maybe im doing something wrong.
Everything sits in a panel that sits in the frame, at end i call:
self.panel.SetSizerAndFit(self.sizer_grid)
Ok, here is how i got it work like i wanted.
Full Code for the Window:
The Important Parts are:
When Adding the List set the flag: wx.EXPAND
Set all columns and rows you want to stretch with SetGrowable. In my example i only want the list to resize vertically and horizontally so i only set the row and column to growable that are the only ones holding the list. With this all other elements stay in their position, is it on the left or right.
Finally adding everything to a vertical Boxsizer with proportion=1 and style wx.EXPAND. Proportion 1 allows the vertical stretch and the wx.EXPAND the horizontal. You could do the same with a horizontal boxsizer i guess. The wx.ALL and ',5' at the end only sets a margin arround the GridBagSizer which looks nicer imo.
PS: The code above needs some functions and custom widgets that are not included.
UltimaListCtrl (with Sorter Mixin):
can be replaced with:
TextCtrlAutoComplete:
which can be removed or replaced.
And a function that adds data and preselect some checkboxes:
This one can be removed as well.