********** wx.PySizer ********** Inheritance diagram for `wx.PySizer`: | .. inheritance-diagram:: wx.PySizer | Description =========== `wx.PySizer` is a special version of `wx.Sizer `_ that has been instrumented to allow the C++ virtual methods to be overloaded in Python derived classes. You would derive from this class if you are wanting to implement a custom sizer in Python code. Simply implement `CalcMin `_ and `RecalcSizes `_ in the derived class and you're all set. For example:: class MySizer(wx.PySizer): """ A simple wx.PySizer derived class. """ def __init__(self): """ Default class constructor. """ wx.PySizer.__init__(self) def CalcMin(self): "Re-implemented from wx.Sizer.CalcMin. """ for item in self.GetChildren(): # Calculate the total minimum width and height needed # by all items in the sizer according to this sizer's # layout algorithm. DoSizeCalculation(item) return wx.Size(width, height) def RecalcSizes(self): "Re-implemented from wx.Sizer.RecalcSizes. """ # Find the space allotted to this sizer pos = self.GetPosition() size = self.GetSize() for item in self.GetChildren(): # Recalculate (if necessary) the position and size of # each item and then call item.SetDimension to do the # actual positioning and sizing of the items within the # space alloted to this sizer. item.SetDimension(itemPos, itemSize) When `Layout `_ is called it first calls `CalcMin `_ followed by `RecalcSizes `_ so you can optimize a bit by saving the results of `CalcMin `_ and reusing them in `RecalcSizes `_. .. seealso:: `wx.SizerItem `_, `wx.Sizer.GetChildren `_ Derived From ^^^^^^^^^^^^^ * `wx.Sizer `_ * `wx.Object `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() Creates a `wx.PySizer`. Must be called from the `__init__` in the derived class. | **Returns:** `wx.PySizer `_