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))
    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)
    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('Sizer.Add: Tuple=%s' % str(self.ts_Size))

        elif isinstance(item, GridSizer):
 
            # Overload the child's wxSizer attribute
            child.Sizer = item
            child.ts_Kind = wx.Item_Sizer
            self.ts_Size = None
            self.logger.debug('Sizer.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('Sizer.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)
    def __init__(self, title):
        '''
        Construct a wx.PyOnDemandOutputWindow object.
        '''
        theClass = 'PyOnDemandStdioWindow'

        wx.RegisterFirstCallerClassName(self, theClass)

##        applicationId = wx.ID_ANY

##        self.tsBeginClassRegistration(theClass, applicationId)

        indent = '--' * 5
        self.logger = tsLogger.TsLogger(
            threshold=tsLogger.DEBUG,
            start=time.time(),
            name=tsLogger.StandardOutputFile)

        self.logger.debug(
            '%s Begin %s (0x%X) after logger import.' % (
                indent, theClass, id(self)))

        # Establish defaults until attributes finalized
        self.ts_ClassName = theClass
        self.ts_Frame = None
        self.ts_Parent = None
        self.ts_Text = None
        self.ts_Title = title

        if wx.ThemeToUse['Stdio']['Title'] == wx.StdioRedirectedTitleStr:

            self.ts_PyOnDemandStdioWindow = True

            self.ts_Name = wx.StdioNameStr
            self.ts_Style = wx.DEFAULT_STDIO_STYLE
            self.ts_logFile = self.tsCreateScrollableRedirectionLog()
            self.ts_Margin = wx.tsGetClassInstanceFromTuple(
                wx.ThemeToUse['Stdio']['Margin'], wxSize)

        else:

            self.ts_PyOnDemandStdioWindow = False

            self.ts_Name = wx.FrameNameStr
            self.ts_Style = wx.DEFAULT_FRAME_STYLE
            self.ts_logFile = None
            self.ts_Margin = wx.tsGetClassInstanceFromTuple(
                wx.ThemeToUse['Stdio']['Margin'], wxSize)

        (thePosition, theSize) = self.tsGetStdioPositionAndSize()
        self.ts_Rect = wxRect(thePosition.x,
                              thePosition.y,
                              theSize.width,
                              theSize.height)

        self.ts_ClientRect = wxRect(
            thePosition.x + wx.pixelWidthPerCharacter,
            thePosition.y + wx.pixelHeightPerCharacter,
            theSize.width - 2 * wx.pixelWidthPerCharacter,
            theSize.height - 2 * wx.pixelHeightPerCharacter)

        self.ts_Cache = wx.EmptyString

        #self.OnCloseClicked = None
        #self.OnHelpClicked = None
        #self.OnMaximizeClicked = None
        #self.OnMinimizeClicked = None
        #self.OnRestoreDownClicked = None
        self.OnClose = None
        self.OnHelp = None
        self.OnMaximize = None
        self.OnMinimize = None
        self.OnRestoreDown = None
 def SetSize(self, size):
     """
     """
     self.ts_Size = wx.tsGetClassInstanceFromTuple(size, wxSize)