def __init__(
        self,
        parent,
        id=wx.ID_ANY,
        label=wx.EmptyString,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        choices=wx.PyEmptyStringArray,
        majorDimension=0,
        style=wx.RA_HORIZONTAL,
        validator=wx.DefaultValidator,
        name=wx.RadioBoxNameStr,
    ):
        """
        Create a Control. Normally you should only call this from a
        subclass __init__ as a plain old wx.Control is not very useful.
        """
        # Also, remember that wx.RA_SPECIFY_COLS means that we arrange buttons
        # in left to right order and GetMajorDim() is the number of columns
        # while wx.RA_SPECIFY_ROWS means that the buttons are arranged top to
        # bottom and GetMajorDim() is the number of rows.
        theClass = "RadioBox"

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_choices = choices
        self.caller_majorDimension = majorDimension
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self, parent, id=id, pos=pos, size=size, style=style, validator=validator, name=name)

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug("               self: %s" % self)
            self.logger.debug("             parent: %s" % parent)
            self.logger.debug("                 id: %s" % self.ts_Id)
            self.logger.debug("         AssignedId: %s" % self.ts_AssignedId)
            self.logger.debug("              label: %s" % label)
            self.logger.debug("                pos: %s" % str(pos))
            self.logger.debug("               size: %s" % str(size))
            self.logger.debug("            choices: %s" % choices)
            self.logger.debug("     majorDimension: %s" % majorDimension)
            self.logger.debug("              style: 0x%X" % style)
            #            self.logger.debug('          validator: 0x%X' % validator)
            self.logger.debug("               name: %s" % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if False:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse["BackgroundColour"].lower()
            self.ts_ForegroundColour = wx.ThemeToUse["ForegroundColour"].lower()
        else:
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        self.ts_Choices = choices
        self.ts_Count = len(choices)
        self.ts_Label = label
        self.ts_MajorDimension = max(majorDimension, self.ts_Count)
        self.ts_Style = style
        self.ts_Validator = validator

        myRect, myClientRect = self.tsRadioBoxLayout(parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        bestSize = self.tsBestSize()
        ##        style = 0

        self.ts_ItemLabel = []
        self.ts_ItemEnabled = []
        self.ts_ItemHelpText = []
        self.ts_ItemToolTip = []
        self.ts_ItemShown = []
        self.ts_ItemWindow = []

        # TBD - Verify scaling.
        if self.ts_Style & wx.RA_HORIZONTAL:
            itemWidth = bestSize.width // (self.ts_MajorDimension + 1)
        else:
            itemWidth = bestSize.width

        for item in range(self.ts_Count):
            self.ts_ItemLabel.append(self.ts_Choices[item])
            self.ts_ItemHelpText.append(self.ts_ItemLabel[item])
            self.ts_ItemToolTip.append(self.ts_ItemLabel[item])
            self.ts_ItemShown.append(True)

            if item == 0:
                self.ts_ItemEnabled.append(True)
            else:
                self.ts_ItemEnabled.append(False)

            # TBD - Under Construction.
            if self.ts_Style & wx.RA_HORIZONTAL:
                # Horizontal layout
                posTBD = wxPoint(
                    self.Rect.x + (item * itemWidth + 2) * wx.pixelWidthPerCharacter,
                    self.Rect.y + (2) * wx.pixelHeightPerCharacter,
                )
            else:
                # Vertical layout
                posTBD = wxPoint(
                    self.Rect.x + (2) * wx.pixelWidthPerCharacter, self.Rect.y + (item + 2) * wx.pixelHeightPerCharacter
                )

            ##            sizeTBD = wxSize(
            ##                (len('(*)  ') + len(
            ##                    self.ts_ItemLabel[item])) * wx.pixelWidthPerCharacter,
            ##                wx.pixelHeightPerCharacter)

            sizeTBD = wxSize(
                (len("(*)  ") + len(self.tsStripAcceleratorTextLabel(self.ts_ItemLabel[item])))
                * wx.pixelWidthPerCharacter,
                wx.pixelHeightPerCharacter,
            )

            self.ts_ItemWindow.append(
                wxRadioButton(
                    self,
                    id=wx.ID_ANY,
                    label=self.ts_ItemLabel[item],
                    pos=posTBD,
                    size=sizeTBD,
                    style=(self.ts_Style & wx.ALIGN_LEFT | self.ts_Style & wx.ALIGN_RIGHT | wx.NO_BORDER),
                    validator=wx.DefaultValidator,
                    name=self.ts_ItemLabel[item],
                )
            )

            self.ts_ItemWindow[item].SetValue(self.ts_ItemEnabled[item])

        if self.ts_Style & wx.RA_HORIZONTAL:
            self.ts_ColumnCount = self.ts_MajorDimension
            self.ts_RowCount = 1

        elif self.ts_Style & wx.RA_VERTICAL:
            self.ts_ColumnCount = 1
            self.ts_RowCount = self.ts_MajorDimension

        else:
            # TBD - Temporary dimension
            self.ts_ColumnCount = self.ts_MajorDimension
            rows, cols = divmod(self.ts_Count, self.ts_MajorDimension)
            if cols == 0:
                self.ts_RowCount = rows
            else:
                self.ts_RowCount = rows + 1

        self.ts_Selection = 0
        self.ts_StringSelection = 0

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event, handler, source, useSystemEventTable=True)

        # Automatically Bind all Radio Button events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_RADIOBUTTON
        handler = self.tsOnRadioButtonClick
        source = self
        self.Bind(event, handler, source, useSystemEventTable=True)

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 label=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.StaticTextNameStr):
        '''
        Create a Control. Normally you should only call this from a subclass
        (_init__) as a plain old wx.Control is not very useful.
        '''
        theClass = 'StaticText'

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % self.Position)
            self.logger.debug('               size: %s' % self.Size)
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('          validator: %s' % validator)
            self.logger.debug('               name: %s' % name)

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        self.ts_BackgroundColour = wx.ThemeToUse['BackgroundColour'].lower()
        self.ts_ForegroundColour = wx.ThemeToUse['ForegroundColour'].lower()
        if False:
            # Facilitate differentiation of this panel from its parent by
            # transposing the parent's foreground and background colors.
            self.ts_BackgroundColour = self.ts_Parent.ts_ForegroundColour
            self.ts_ForegroundColour = self.ts_Parent.ts_BackgroundColour
        else:
            self.ts_BackgroundColour = self.ts_Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.ts_Parent.ts_ForegroundColour

        self.ts_Style = style

        self.ts_TheWrapper = None

        self.ts_Name = name
        self.ts_ButtonText = label

        myRect, myClientRect = self.tsStaticTextLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_SET_FOCUS
        handler = self.SetFocusFromKbd
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        if True:
            self.tsShow()

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 value=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.TextCtrlNameStr):
        '''
        Create a Control. Normally you should only call this from a subclass
        (_init__) as a plain old wx.Control is not very useful.
        '''
        theClass = 'TextCtrl'

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_value = value
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              value: %s' % value)
            self.logger.debug('                pos: %s' % self.Position)
            self.logger.debug('               size: %s' % self.Size)
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('          validator: %s' % validator)
            self.logger.debug('               name: %s' % name)

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:

            self.ts_GrandParent = None

        else:

            self.ts_GrandParent = parent.Parent

        if False:

            self.ts_BackgroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()

            self.ts_ForegroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()

        elif  (self.tsCursesHasColors):

            self.ts_BackgroundColour = self.ts_Parent.ts_BackgroundColour

            self.ts_ForegroundColour = self.ts_Parent.ts_ForegroundColour

        else:

            self.ts_BackgroundColour = None

            self.ts_ForegroundColour = None

        self.ts_Style = style

        self.ts_Name = name
        self.ts_Label = value
        self.ts_Text = value
        self.ts_Row = 0
        self.ts_Col = 0
        self.ts_LineNumber = 0

        myRect, myClientRect = self.tsTextCtrlLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        if True:
            self.tsShow()

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_SET_FOCUS
        handler = self.SetFocusFromKbd
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 value=0,
                 minValue=0,
                 maxValue=100,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.SL_HORIZONTAL,
                 validator=wx.DefaultValidator,
                 name=wx.SliderNameStr):
        '''
        Create a Control. Normally you should only call this from a
        subclass __init__ as a plain old wx.Control is not very useful.
        '''
        theClass = 'Slider'

        # TBD - Set default label
        label = None

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        self.tsBeginClassRegistration(theClass, id)

        # TBD - Set default label
        label = None

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % str(pos))
            self.logger.debug('               size: %s' % str(size))
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if False:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()
        else:
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        self.ts_Style = style

        self.ts_ButtonText = label
        self.ts_Label = label
        self.ts_Validator = validator
        self.ts_Value = False

        myRect, myClientRect = self.tsSliderLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 range=100,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.SB_HORIZONTAL,
                 validator=wx.DefaultValidator,
                 name=wx.ScrollBarGaugeNameStr):
        '''
        Create a Control. Normally you should only call this from a
        subclass __init__ as a plain old wx.Control is not very useful.
        '''
        theClass = 'ScrollBarGauge'

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_range = range
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              range: %s' % range)
            self.logger.debug('                pos: %s' % str(pos))
            self.logger.debug('               size: %s' % str(size))
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if True:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse[
                'ScrollBar']['BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'ScrollBar']['ForegroundColour'].lower()
        else:
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        self.ts_Style = style

        if (((self.ts_Style & wx.SB_HORIZONTAL) == wx.SB_HORIZONTAL) or \
            ((self.ts_Style & wx.HSCROLL) == wx.HSCROLL)):
            self.ts_Orientation = wx.SB_HORIZONTAL
        else:
            self.ts_Orientation = wx.SB_VERTICAL

        myRect, myClientRect = self.tsScrollBarGaugeLayout(
            parent, pos, size, style, name)

        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        ####################################################################
        # Begin linkage setup for distributed mouse click handling
        #     SetChildForText enables Scrolled and/or ScrollBar to
        #     establish linkage between ScrollBarButton and
        #     ScrolledText.
        try:

            # Assume normal usage hierarchy
            self.ts_ScrollBar    = self.ts_Parent
            self.ts_Scrolled     = self.ts_ScrollBar.ts_Parent
            # Assume tsSetChildForText not yet used to override target
            self.ts_ScrolledText = self.ts_Scrolled.ts_ChildForText

        except Exception as errorCode:

            msg = 'tsWxScrollBarGauge.__init__: errorCode=%s' % str(errorCode)
            print('ERROR: %s\n' % msg)
            self.logger.error(msg)
            raise tse.ProgramException(tse.APPLICATION_TRAP, msg)

            # Assume unit test usage hierarchy
            self.ts_Scrolled = None
            # Assume DEBUG mode for test_tsWxScrollBar
            self.ts_ScrolledText = self
        # End linkage setup for distributed mouse click handling
        ####################################################################

        self.ts_BarGraph = []
        self.ts_Range = range

        self.ts_GaugeThumbLines = 0

        self.ts_ChildForText = None

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        # Postpone Automatic Bind of all ScrollBarGauge events until
        # parent has invoked tsSetChildForText.
        self.ts_TriggeringCriteria = None
        self.ts_TriggeringEvent = None

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 label=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.RadioButtonNameStr):
        '''
        '''
        theClass = 'RadioButton'

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % str(pos))
            self.logger.debug('               size: %s' % str(size))
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if False:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()
        else:
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        self.ts_Style = (style & wx.ALIGN_LEFT) | (style & wx.ALIGN_RIGHT)

        self.ts_Label = label
        self.ts_ButtonText = self.tsStripAcceleratorTextLabel(label)

        self.ts_Validator = validator
        self.ts_Value = wx.CHK_UNCHECKED

        myRect, myClientRect = self.tsRadioButtonLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 label=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.StaticBoxNameStr,
                 useClientArea = True):
        '''
        Create a Control. Normally you should only call this from a subclass
        (_init__) as a plain old wx.Control is not very useful.
        '''
        theClass = 'StaticBox'

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % str(pos))
            self.logger.debug('               size: %s' % str(size))
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = parent
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if False:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()
        else:
            # Inter-StaticBox spaces have same color as parent background.
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        # Facilitate differentiation of this panel from its parent by
        # transposing the parent's foreground and background colors.
        if style == wx.BORDER_SUNKEN:

            self.ts_BackgroundColour = wx.COLOR_BLACK
            self.ts_ForegroundColour = wx.COLOR_WHITE

        elif style == wx.BORDER_RAISED:

            self.ts_BackgroundColour = wx.COLOR_WHITE
            self.ts_ForegroundColour = wx.COLOR_BLACK

        else:

            self.ts_BackgroundColour = self.ts_Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.ts_Parent.ts_ForegroundColour

        self.ts_Style = style

        self.ts_Label = label
        self.ts_StaticBoxText = self.tsStripAcceleratorTextLabel(label)

        self.ts_UseClientArea = useClientArea
        self.ts_Validator = validator

        (myRect, myClientRect) = self.tsStaticBoxLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 label=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.ButtonNameStr,
                 useClientArea=True):
        '''
        Create and show a button. The preferred way to create standard buttons
        is to use a standard ID and an empty label. In this case wxWigets will
        automatically use a stock label that corresponds to the ID given.
        These labels may vary across platforms as the platform itself will
        provide the label if possible. In addition, the button will be
        decorated with stock icons under GTK+ 2.
        '''
        theClass = 'Button'

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % str(pos))
            self.logger.debug('               size: %s' % str(size))
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if False:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()
        else:
            # Inter-button spaces have same color as parent background.
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        self.ts_Style = style

        self.ts_Label = label
        self.ts_ButtonText = self.tsStripAcceleratorTextLabel(label)

        self.ts_UseClientArea = useClientArea
        self.ts_Validator = validator

        (myRect, myClientRect) = self.tsButtonLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        self.tsEndClassRegistration(theClass)
    def __init__(self):
        '''
        Create a Control. Normally you should only call this from a
        subclass __init__ as a plain old wx.Control is not very useful.
        '''
        theClass = 'ControlWithItems'

##        # Capture initial caller parametsrs before they are changed
##        self.caller_parent = parent
##        self.caller_id = id
##        self.caller_label = label
##        self.caller_pos = pos
##        self.caller_size = size
##        self.caller_style = style
##        self.caller_validator = validator
##        self.caller_name = name

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         self.ts_parent,
                         id=self.ts_Id,
                         pos=self.ts_pos,
                         size=self.ts_size,
                         style=self.ts_style,
                         validator=self.ts_validator,
                         name=self.ts_name)

        ItemContainer.__init__(self)

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % self.ts_parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
##            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % str(self.ts_pos))
            self.logger.debug('               size: %s' % str(self.ts_size))
            self.logger.debug('              style: 0x%X' % self.ts_style)
            self.logger.debug('          validator: %s' % self.ts_validator)
            self.logger.debug('               name: %s' % self.ts_name)

##        self.ts_Default = False

##        self.ts_Name = name
##        self.ts_Parent = parent
##        if parent is None:
##            self.ts_GrandParent = None
##        else:
##            self.ts_GrandParent = parent.Parent

##        if False:
##            # Leaves artifacts of different color than parent background.
##            self.ts_BackgroundColour = wx.ThemeToUse[
##                'BackgroundColour'].lower()
##            self.ts_ForegroundColour = wx.ThemeToUse[
##                'ForegroundColour'].lower()
##        else:
##            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
##            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

##        self.ts_Style = style

##        self.ts_ButtonText = label
##        self.ts_Label = label
##        self.ts_Validator = validator
##        self.ts_Value = False

##        myRect, myClientRect = self.tsButtonLayout(
##            parent, pos, size, style, name)
##        self.ts_Rect = myRect
##        self.ts_ClientRect = myClientRect

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 value=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.ScrolledTextNameStr):
        '''
        Create a Control. Normally you should only call this from a subclass
        (_init__) as a plain old wx.Control is not very useful.
        '''
        theClass = 'ScrolledText'

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_value = value
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              value: %s' % value)
            self.logger.debug('                pos: %s' % self.Position)
            self.logger.debug('               size: %s' % self.Size)
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('          validator: %s' % validator)
            self.logger.debug('               name: %s' % name)

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:

            self.ts_GrandParent = None

        else:

            self.ts_GrandParent = parent.Parent

        if False:

            self.ts_BackgroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()

            self.ts_ForegroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()

        elif  (self.tsCursesHasColors):

            self.ts_BackgroundColour = self.ts_Parent.ts_BackgroundColour

            self.ts_ForegroundColour = self.ts_Parent.ts_ForegroundColour

        else:

            self.ts_BackgroundColour = None

            self.ts_ForegroundColour = None

        self.ts_Style = style

        self.ts_Name = name
        self.ts_Label = value
        self.ts_Text = value
        self.ts_Row = 0
        self.ts_Col = 0
        self.ts_LineNumber = 0

        myRect, myClientRect = self.tsScrolledTextLayout(
            parent, pos, size, style, name)
        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        #-------------------------------------------------------------------

        # Begin Scrolled Class Instance Variable Initialization
        # The following definitions are required to resolve
        # pylint warnings about definitions outside of __init__.
        self.curLine = []
        self.drawing = False

        self.ts_AutoScrolling = False
        self.ts_MaxTextCols = 0
        self.ts_MaxTextRows = 0
        self.ts_Retained = False
        self.ts_ScaleX = float(1.0) # 0.0 in wxWidgets
        self.ts_ScaleY = float(1.0) # 0.0 in wxWidgets
        self.ts_ScrolledTextLines = []
        self.ts_ScrolledTextMarkup = []
        self.ts_TargetWindow = None
        self.ts_ViewStart = False
        self.ts_Window = self # TBD - Is this required and appropriate

        #-------------------------------------------------------------------

        self.ts_xScrollLines = 0
        self.ts_xScrollLinesPerPage = (
            myClientRect.width // wx.pixelWidthPerCharacter)
        self.ts_xScrollPixelsPerLine = wx.pixelWidthPerCharacter
        self.ts_xScrollPosition = 0

        parentStyle = self.Parent.ts_Style

        if (((parentStyle & wx.SB_HORIZONTAL) == wx.SB_HORIZONTAL) or \
            ((parentStyle & wx.HSCROLL) == wx.HSCROLL)):

            self.ts_ChildForHorizontalScrollBar = None
            self.ts_xScrollingEnabled = True

            self.Bind(EVT_HSCROLLWIN_BOTTOM, self.tsOnHScrollWinBottom)
            self.Bind(EVT_HSCROLLWIN_LINEDOWN, self.tsOnHScrollWinLineDown)
            self.Bind(EVT_HSCROLLWIN_LINEUP, self.tsOnHScrollWinLineUp)
            self.Bind(EVT_HSCROLLWIN_PAGEDOWN, self.tsOnHScrollWinPageDown)
            self.Bind(EVT_HSCROLLWIN_PAGEUP, self.tsOnHScrollWinPageUp)
            self.Bind(EVT_HSCROLLWIN_TOP, self.tsOnHScrollWinTop)

        else:

            self.ts_ChildForHorizontalScrollBar = None
            self.ts_xScrollingEnabled = False

        #-------------------------------------------------------------------

        self.ts_yScrollLines = 0
        self.ts_yScrollLinesPerPage = (
            myClientRect.height // wx.pixelHeightPerCharacter)
        self.ts_yScrollPixelsPerLine = wx.pixelHeightPerCharacter
        self.ts_yScrollPosition = 0

        if (((parentStyle & wx.SB_VERTICAL) == wx.SB_VERTICAL) or \
            ((parentStyle & wx.VSCROLL) == wx.VSCROLL)):

            self.ts_ChildForVerticalScrollBar = None
            self.ts_yScrollingEnabled = True

            self.Bind(EVT_VSCROLLWIN_BOTTOM, self.tsOnVScrollWinBottom)
            self.Bind(EVT_VSCROLLWIN_LINEDOWN, self.tsOnVScrollWinLineDown)
            self.Bind(EVT_VSCROLLWIN_LINEUP, self.tsOnVScrollWinLineUp)
            self.Bind(EVT_VSCROLLWIN_PAGEDOWN, self.tsOnVScrollWinPageDown)
            self.Bind(EVT_VSCROLLWIN_PAGEUP, self.tsOnVScrollWinPageUp)
            self.Bind(EVT_VSCROLLWIN_TOP, self.tsOnVScrollWinTop)

        else:

            self.ts_ChildForVerticalScrollBar = None
            self.ts_yScrollingEnabled = False
 
        # End Scrolled Class Instance Variable Initialization

        #-------------------------------------------------------------------

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_SET_FOCUS
        handler = self.SetFocusFromKbd
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)


        if True:
            self.tsShow()

        self.tsEndClassRegistration(theClass)
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 label=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=0,
                 validator=wx.DefaultValidator,
                 name=wx.ScrollBarButtonNameStr,
                 useClientArea=True):
        '''
        Create and show a button. The preferred way to create standard buttons
        is to use a standard ID and an empty label. In this case wxWigets will
        automatically use a stock label that corresponds to the ID given.
        These labels may vary across platforms as the platform itself will
        provide the label if possible. In addition, the button will be
        decorated with stock icons under GTK+ 2.
        '''
        theClass = 'ScrollBarButton'

        wx.RegisterFirstCallerClassName(self, theClass)

        Control.__init__(self,
                         parent,
                         id=id,
                         pos=pos,
                         size=size,
                         style=style,
                         validator=validator,
                         name=name)

        # Capture initial caller parametsrs before they are changed
        self.caller_parent = parent
        self.caller_id = id
        self.caller_label = label
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_validator = validator
        self.caller_name = name

        self.tsBeginClassRegistration(theClass, id)

        if DEBUG:
            self.logger.debug('               self: %s' % self)
            self.logger.debug('             parent: %s' % parent)
            self.logger.debug('                 id: %s' % self.ts_Id)
            self.logger.debug('         AssignedId: %s' % self.ts_AssignedId)
            self.logger.debug('              label: %s' % label)
            self.logger.debug('                pos: %s' % str(pos))
            self.logger.debug('               size: %s' % str(size))
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Default = False

        self.ts_Name = name
        self.ts_Parent = parent

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

        if parent is None:
            self.ts_GrandParent = None
        else:
            self.ts_GrandParent = parent.Parent

        if False:
            # Leaves artifacts of different color than parent background.
            self.ts_BackgroundColour = wx.ThemeToUse[
                'ScrollBar']['ForegroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'ScrollBar']['BackgroundColour'].lower()
        else:
            # Inter-button spaces have same color as parent background.
            self.ts_BackgroundColour = self.Parent.ts_BackgroundColour
            self.ts_ForegroundColour = self.Parent.ts_ForegroundColour

        self.ts_Style = style

        self.ts_Label = label
        self.ts_ButtonText = self.tsStripAcceleratorTextLabel(label)

        self.ts_ArrowDownEnabled = False
        self.ts_ArrowLeftEnabled = False
        self.ts_ArrowRightEnabled = False
        self.ts_ArrowUpEnabled = False

        if self.GetLabel().find(wx.ThemeToUse['ScrollBar'][
            'ArrowUp']) > -1:

            self.ts_ArrowUpEnabled = True

        elif self.GetLabel().find(wx.ThemeToUse['ScrollBar'][
            'ArrowDown']) > -1:

            self.ts_ArrowDownEnabled = True

        elif self.GetLabel().find(wx.ThemeToUse['ScrollBar'][
            'ArrowLeft']) > -1:

            self.ts_ArrowLeftEnabled = True

        elif self.GetLabel().find(wx.ThemeToUse['ScrollBar'][
            'ArrowRight']) > -1:

            self.ts_ArrowRightEnabled = True

        else:

            msg = 'tsWxScrollBarButton.__init__: ' + \
                'Invalid Arrow=%s' % self.GetLabel()
            self.logger.error(msg)
            raise tse.ProgramException(tse.APPLICATION_TRAP, msg)

        self.ts_UseClientArea = useClientArea
        self.ts_Validator = validator

        (myRect, myClientRect) = self.tsScrollBarButtonLayout(
            parent, pos, size, style, name)

        self.ts_Rect = myRect
        self.ts_ClientRect = myClientRect

        ####################################################################
        # Begin linkage setup for distributed mouse click handling
        #     SetChildForText enables Scrolled and/or ScrollBar to
        #     establish linkage between ScrollBarButton and
        #     ScrolledText.
        try:
            # Assume normal usage hierarchy
            self.ts_ScrollBar    = self.ts_Parent
            self.ts_Scrolled     = self.ts_ScrollBar.ts_Parent
            # Assume tsSetChildForText not yet used to override target
            self.ts_ScrolledText = self.ts_Scrolled.ts_ChildForText
        except Exception as errorCode:
            msg = 'tsWxScrollBarButton.__init__: errorCode=%s' % str(errorCode)
            print('ERROR: %s\n' % msg)
            self.logger.error(msg)
            raise tse.ProgramException(tse.APPLICATION_TRAP, msg)

            # Assume unit test usage hierarchy
            self.ts_Scrolled = None
            # Assume DEBUG mode for test_tsWxScrollBar
            self.ts_ScrolledText = self
        # End linkage setup for distributed mouse click handling
        ####################################################################

        # Automatically Bind all mouse events ASAP (now).
        # Will register event in the SystemEventTable.
        event = EVT_COMMAND_LEFT_CLICK
        handler = self.tsOnLeftClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        event = EVT_COMMAND_LEFT_DCLICK
        handler = self.tsOnLeftDClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        event = EVT_COMMAND_RIGHT_CLICK
        handler = self.tsOnRightClick
        source = self
        self.Bind(event,
                  handler,
                  source,
                  useSystemEventTable=True)

        self.tsEndClassRegistration(theClass)