X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/951090428fd85dd275a4cb87e340b3c9ceae3406..9f93b45e59e93e17850bbc37a8960240072bc1c0:/wxPython/src/_sizers.i 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) + } }; //---------------------------------------------------------------------------