Sorry if this is a duplicate, but my other post isn’t showing up, so just want to make sure it worked. I need a gridsizer that can be made to be column-major instead of row-major, meaning that i would like it to fill up the column, then move to the next column, instead of filling up the row and then moving to the next row. I have a long list of checkboxes that would make more sense in a column major format. Here is what i mean
This is the current format for just a standard wx.GridSizer:
1 2 3
4 5 6
7 8 9
This is what i would like:
1 4 7
2 5 8
3 6 9
Obviously i could alter the order in which i add the checkboxes to the grid sizer and achieve the same thing, but i would like a far more elegant solution. If anyone knows how to change this or use any other type of sier that would achieve the same thing, please let me know!
See the demo/documentation for the wx.GridBagSizer, which allows adding of elements by explicitly specifying the grid coordinates by mysizer.Add(element, (row, col))
This is unfortunately not what you asked for, but maybe it is elegant enough:
myelements = [wxObject1, wxObject2, …]
el_per_col= n
for i, obj in enumerate(mylements):
mysizer.Add(obj, (i - i % el_per_col)/el_per_col, i % el_per_col)
(untested)
···
On Tuesday, November 12, 2013 3:49:14 PM UTC+1, Seth Mayfield wrote:
That was very nearly exactly what I wanted! The only thing that needed changing was in mysizer.Add
the X and Y components needed to be flipped to mysizer.Add(obj, i % el_per_col,(i - i % el_per_col)/el_per_col)
Thank you so much. Elegant and effective
···
On Wednesday, November 13, 2013 11:52:19 AM UTC-6, nepix32 wrote:
On Tuesday, November 12, 2013 3:49:14 PM UTC+1, Seth Mayfield wrote:
[column-wise adding of elements in wx.GridSizer]
See the demo/documentation for the wx.GridBagSizer, which allows adding of elements by explicitly specifying the grid coordinates by mysizer.Add(element, (row, col))
Thanks
myelements = [wxObject1, wxObject2, …]
el_per_col= n
for i, obj in enumerate(mylements):
mysizer.Add(obj, (i - i % el_per_col)/el_per_col, i % el_per_col)