X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/951090428fd85dd275a4cb87e340b3c9ceae3406..c4287548985b4a8246eb1d9b4ced2f346fc95253:/wxPython/src/_sizers.i diff --git a/wxPython/src/_sizers.i b/wxPython/src/_sizers.i index f3482de61e..9726d7b4fc 100644 --- a/wxPython/src/_sizers.i +++ b/wxPython/src/_sizers.i @@ -23,10 +23,13 @@ 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`", ""); @@ -357,8 +360,8 @@ DocStr(wxSizer, "wx.Sizer is the abstract base class used for laying out subwindows in a window. You cannot use wx.Sizer directly; instead, you will have to use one of the sizer classes derived from it such as `wx.BoxSizer`, -`wx.StaticBoxSizer`, `wx.NotebookSizer`, `wx.GridSizer`, `wx.FlexGridSizer` -and `wx.GridBagSizer`. +`wx.StaticBoxSizer`, `wx.GridSizer`, `wx.FlexGridSizer` and +`wx.GridBagSizer`. The concept implemented by sizers in wxWidgets is closely related to layout tools in other GUI toolkits, such as Java's AWT, the GTK @@ -1179,6 +1182,25 @@ define extra space between all children.", ""); 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) + } }; //---------------------------------------------------------------------------