DocStr(wxSizerItem,
"The wx.SizerItem class is used to track the position, size and other
-attributes of each item managed by a `wx.Sizer`. In normal usage user
-code should never need to deal directly with a wx.SizerItem, but
-custom classes derived from `wx.PySizer` will probably need to use the
-collection of wx.SizerItems held by wx.Sizer when calculating layout.
+attributes of each item managed by a `wx.Sizer`. It is not usually
+necessary to use this class because the sizer elements can also be
+identified by their positions or window or sizer references but
+sometimes it may be more convenient to use wx.SizerItem directly.
+Also, custom classes derived from `wx.PySizer` will probably need to
+use the collection of wx.SizerItems held by wx.Sizer when calculating
+layout.
:see: `wx.Sizer`, `wx.GBSizerItem`", "");
DocAStr(IsShown,
"IsShown(self, item)",
- "Determines if the item is currently shown. sizer. To make a sizer
+ "Determines if the item is currently shown. To make a sizer
item disappear or reappear, use Show followed by `Layout`. The *item*
parameter can be either a window, a sizer, or the zero-based index of
the item.", "");
void , ShowItems(bool show),
"Recursively call `wx.SizerItem.Show` on all sizer items.", "");
- // TODO:
- // void Show(bool show);
- // bool IsShown();
-
};
int , GetHGap(),
"Returns the horizontal gap (in pixels) between cells in the sizer.", "");
+ %pythoncode {
+ def CalcRowsCols(self):
+ """
+ CalcRowsCols() -> (rows, cols)
+
+ Calculates how many rows and columns will be in the sizer based
+ on the current number of items and also the rows, cols specified
+ in the constructor.
+ """
+ nitems = len(self.GetChildren())
+ rows = self.GetRows()
+ cols = self.GetCols()
+ assert rows != 0 or cols != 0, "Grid sizer must have either rows or columns fixed"
+ if cols != 0:
+ rows = (nitems + cols - 1) / cols
+ elif rows != 0:
+ cols = (nitems + rows - 1) / rows
+ return (rows, cols)
+ }
};
//---------------------------------------------------------------------------