コード例 #1
0
    def SetRatioSize(self, size):
        """
        Set the ratio item attribute.

        Modeled after SetRatioSize in sizer.cpp file of wxWidgets.
        """
        mySize = wx.tsGetClassInstanceFromTuple(size, wxSize)
        if mySize.height > 0:
            self.SetRatio(float(mySize.width) / float(mySize.height))
        else:
            self.SetRatio(float(1.0))
コード例 #2
0
    def SetSpacer(self, size):
        """
        Set the size of the spacer to be managed by this sizer item.

        Modeled after SetSpacer in sizer.h file of wxWidgets.
        """
        self.logger.wxASSERT_MSG((size is None), "SizerItem.SetSpacer size cannot be %s." % size)

        self.ts_Kind = wx.Item_Spacer

        theSize = wx.tsGetClassInstanceFromTuple(size, wxSize)
        self.ts_Spacer = wxSizerSpacer(theSize)
        self.ts_MinSize = theSize
        self.SetRatio(theSize)
コード例 #3
0
    def Add(self, item, proportion=0, flag=0, border=0, userData=None):
        '''
        Appends a child to the sizer.

        wxSizer itself is an abstract class, but the parameters are
        equivalent in the derived classes that you will instantiate to
        use it so they are described here:

        Parameters:
        window  The window to be added to the sizer. Its initial size
        (either set explicitly by the user or calculated internally when
        using wxDefaultSize) is interpreted as the minimal and in many
        cases also the initial size.

        proportion      Although the meaning of this parameter is
        undefined in wxSizer, it is used in wxBoxSizer to indicate if a
        child of a sizer can change its size in the main orientation of
        the wxBoxSizer - where 0 stands for not changeable and a value
        of more than zero is interpreted relative to the value of other
        children of the same wxBoxSizer. For example, you might have a
        horizontal wxBoxSizer with three children, two of which are
        supposed to change their size with the sizer. Then the two
        stretchable windows would get a value of 1 each to make them
        grow and shrink equally with the sizers horizontal dimension.

        flag OR-combination of flags affecting sizers behaviour.
        See wxSizer flags list for details.

        border Determines the border width, if the flag parameter is
        set to include any border flag.

        userData Allows an extra object to be attached to the
        sizer item, for use in derived classes when sizing information
        is more complex than the proportion and flag will allow for.
        '''
        # Create new SizerItem with default addributes
        child = wxSizerItem()

        if isinstance(item, tuple) or \
           isinstance(item, wxSize):

            # Overload the child's wxSizerSpacer attribute
            child.ts_Size = wx.tsGetClassInstanceFromTuple(item, wxSize)
            child.ts_Kind = wx.Item_Spacer
            self.ts_Size = child.ts_Size
            self.logger.debug(
                'StaticBoxSizer.Add: Tuple=%s' % str(self.ts_Size))

        elif isinstance(item, StaticBoxSizer):
 
            # Overload the child's wxSizer attribute
            child.Sizer = item
            child.ts_Kind = wx.Item_Sizer
            self.ts_Size = None
            self.logger.debug(
                'StaticBoxSizer.Add: Sizer=%s' % str(self.ts_Size))

        else:

            # Overload the child's window attribute
            # Supports Top Level Windows (i.e., Dialogs and Frames)
            # Supports Lower Level Windows (i.e., Buttons, Check Boxes,
            # Gauges, Panels, Radio Boxes, Radio Buttons etc.).
            child.Window = item
            child.ts_Kind = wx.Item_Window
            try:
                self.ts_Size = item.ts_Size
            except AttributeError:
                self.ts_Size = DEFAULT_SIZE
            self.logger.debug(
                'StaticBoxSizer.Add: Window=%s' % str(self.ts_Size))

        # Overload the child's other attributes
        child.Proportion = proportion
        child.Flag = flag
        child.Border = border
        child.UserData = userData

        # Register the child in the wxSizerItemList
        self.ts_Children.Add(child)
 
        return (child)