Package wx :: Class PySizer
[frames | no frames]

Type PySizer

object --+        
         |        
    Object --+    
             |    
         Sizer --+
                 |
                PySizer

Known Subclasses:
PyGridSizer, RowColSizer, TableSizer

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):
     def __init__(self):
         wx.PySizer.__init__(self)

     def CalcMin(self):
         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.
              ...
         return wx.Size(width, height)

      def RecalcSizes(self):
          # 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.


See Also:

wx.SizerItem, wx.Sizer.GetChildren

Method Summary
PySizer __init__(self)
Creates a wx.PySizer.

Property Summary
  thisown: The membership flag

Method Details

__init__(self)
(Constructor)

Creates a wx.PySizer. Must be called from the __init__ in the derived class.

Returns:
PySizer
Overrides:
wx.Sizer.__init__

Property Details

thisown

The membership flag


Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:54:40 2009 http://epydoc.sf.net