From: Robin Dunn Date: Fri, 24 Feb 2006 01:12:40 +0000 (+0000) Subject: Add CalcRowsCols X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c86fa5a1fa18ea1cd4c706e69f879d0928b92f07 Add CalcRowsCols git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37691 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/src/_sizers.i b/wxPython/src/_sizers.i index f3482de61e..dfe3c191c1 100644 --- a/wxPython/src/_sizers.i +++ b/wxPython/src/_sizers.i @@ -1179,6 +1179,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) + } }; //---------------------------------------------------------------------------