wx.FlexGridSizer¶
A flex grid sizer is a sizer which lays out its children in a two-dimensional table with all table fields in one row having the same height and all fields in one column having the same width, but all rows or all columns are not necessarily the same height or width as in the wx.GridSizer.
Since wxWidgets 2.5.0, wx.FlexGridSizer can also size items equally in one direction but unequally (“flexibly”) in the other. If the sizer is only flexible in one direction (this can be changed using wx.FlexGridSizer.SetFlexibleDirection
), it needs to be decided how the sizer should grow in the other (“non-flexible”) direction in order to fill the available space. The wx.FlexGridSizer.SetNonFlexibleGrowMode
method serves this purpose.
See also
Class Hierarchy¶
Known Subclasses¶
Methods Summary¶
wx.FlexGridSizer constructors. |
|
Specifies that column idx (starting from zero) should be grown if there is extra space available to the sizer. |
|
Specifies that row idx (starting from zero) should be grown if there is extra space available to the sizer. |
|
This method is abstract and has to be overwritten by any derived class. |
|
Returns a read-only array containing the widths of the columns in the sizer. |
|
Returns a wx.Orientation value that specifies whether the sizer flexibly resizes its columns, rows, or both (default). |
|
Returns the value that specifies how the sizer grows in the “non-flexible” direction if there is one. |
|
Returns a read-only array containing the heights of the rows in the sizer. |
|
Returns |
|
Returns |
|
Specifies that the idx column index is no longer growable. |
|
Specifies that the idx row index is no longer growable. |
|
Method which must be overridden in the derived sizer classes. |
|
Specifies whether the sizer should flexibly resize its columns, rows, or both. |
|
Specifies how the sizer should grow in the non-flexible direction if there is one (so |
Properties Summary¶
See |
|
See |
Class API¶
- class wx.FlexGridSizer(GridSizer)¶
Possible constructors:
FlexGridSizer(cols, vgap, hgap) -> None FlexGridSizer(cols, gap=Size(0,0)) -> None FlexGridSizer(rows, cols, vgap, hgap) -> None FlexGridSizer(rows, cols, gap) -> None
A flex grid sizer is a sizer which lays out its children in a two- dimensional table with all table fields in one row having the same height and all fields in one column having the same width, but all rows or all columns are not necessarily the same height or width as in the GridSizer.
Methods¶
- __init__(self, *args, **kw)¶
wx.FlexGridSizer constructors.
Please see
GridSizer.__init__
documentation.Added in version 2.9.1: (except for the four argument overload)
__init__ (self, cols, vgap, hgap)
- Parameters:
cols (int)
vgap (int)
hgap (int)
- Return type:
None
__init__ (self, cols, gap=Size(0,0))
- Parameters:
cols (int)
gap (wx.Size)
- Return type:
None
__init__ (self, rows, cols, vgap, hgap)
- Parameters:
rows (int)
cols (int)
vgap (int)
hgap (int)
- Return type:
None
__init__ (self, rows, cols, gap)
- Parameters:
rows (int)
cols (int)
gap (wx.Size)
- Return type:
None
- AddGrowableCol(self, idx, proportion=0)¶
Specifies that column idx (starting from zero) should be grown if there is extra space available to the sizer.
The proportion parameter has the same meaning as the stretch factor for the sizers (see wx.BoxSizer) except that if all proportions are 0, then all columns are resized equally (instead of not being resized at all).
Notice that the column must not be already growable, if you need to change the proportion you must call
RemoveGrowableCol
first and then make it growable (with a different proportion) again. You can useIsColGrowable
to check whether a column is already growable.- Parameters:
idx (int)
proportion (int)
- Return type:
None
- AddGrowableRow(self, idx, proportion=0)¶
Specifies that row idx (starting from zero) should be grown if there is extra space available to the sizer.
This is identical to
AddGrowableCol
except that it works with rows and not columns.- Parameters:
idx (int)
proportion (int)
- Return type:
None
- CalcMin(self)¶
This method is abstract and has to be overwritten by any derived class.
Here, the sizer will do the actual calculation of its children’s minimal sizes.
- Return type:
- GetColWidths(self)¶
Returns a read-only array containing the widths of the columns in the sizer.
- Return type:
List[int]
- GetFlexibleDirection(self)¶
Returns a wx.Orientation value that specifies whether the sizer flexibly resizes its columns, rows, or both (default).
- Return type:
int
- Returns:
One of the following values:
wx.VERTICAL
: Rows are flexibly sized.wx.HORIZONTAL
: Columns are flexibly sized.wx.BOTH
: Both rows and columns are flexibly sized (this is the default value).
See also
- GetNonFlexibleGrowMode(self)¶
Returns the value that specifies how the sizer grows in the “non-flexible” direction if there is one.
The behaviour of the elements in the flexible direction (i.e. both rows and columns by default, or rows only if
GetFlexibleDirection
isVERTICAL
or columns only if it isHORIZONTAL
) is always governed by their proportion as specified in the call toAddGrowableRow
orAddGrowableCol
. What happens in the other direction depends on the value of returned by this function as described below.- Return type:
- Returns:
One of the following values:
wx.FLEX_GROWMODE_NONE
: Sizer doesn’t grow its elements at all in the non-flexible direction.wx.FLEX_GROWMODE_SPECIFIED
: Sizer honors growable columns/rows set withAddGrowableCol
andAddGrowableRow
in the non-flexible direction as well. In this case equal sizing applies to minimum sizes of columns or rows (this is the default value).wx.FLEX_GROWMODE_ALL
: Sizer equally stretches all columns or rows in the non-flexible direction, independently of the proportions applied in the flexible direction.
See also
- GetRowHeights(self)¶
Returns a read-only array containing the heights of the rows in the sizer.
- Return type:
List[int]
- IsColGrowable(self, idx)¶
Returns
True
if column idx is growable.- Parameters:
idx (int)
- Return type:
bool
Added in version 2.9.0.
- IsRowGrowable(self, idx)¶
Returns
True
if row idx is growable.- Parameters:
idx (int)
- Return type:
bool
Added in version 2.9.0.
- RemoveGrowableCol(self, idx)¶
Specifies that the idx column index is no longer growable.
- Parameters:
idx (int)
- Return type:
None
- RemoveGrowableRow(self, idx)¶
Specifies that the idx row index is no longer growable.
- Parameters:
idx (int)
- Return type:
None
- RepositionChildren(self, minSize)¶
Method which must be overridden in the derived sizer classes.
The implementation should reposition the children using the current total size available to the sizer (
m_size
) and the size computed by the last call toCalcMin
.Note that you should never call this method directly, call
Layout
instead if you need to manually update the sizer elements positions. This method is only called by wxWidgets itself.- Parameters:
minSize (wx.Size)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.3: , before this version RecalcSizes() method not taking any arguments had to be overridden in the derived classes instead.
- SetFlexibleDirection(self, direction)¶
Specifies whether the sizer should flexibly resize its columns, rows, or both.
Argument direction can be
VERTICAL
,HORIZONTAL
orBOTH
(which is the default value). Any other value is ignored.See
GetFlexibleDirection
for the explanation of these values. Note that this method does not trigger relayout.- Parameters:
direction (int)
- Return type:
None
- SetNonFlexibleGrowMode(self, mode)¶
Specifies how the sizer should grow in the non-flexible direction if there is one (so
SetFlexibleDirection
must have been called previously).Argument mode can be one of those documented in
GetNonFlexibleGrowMode
, please see there for their explanation. Note that this method does not trigger relayout.- Parameters:
mode (FlexSizerGrowMode)
- Return type:
None
Properties¶
- ColWidths¶
See
GetColWidths
- FlexibleDirection¶
- NonFlexibleGrowMode¶
- RowHeights¶
See
GetRowHeights