コード例 #1
0
    def __init__(self,
                 parent,                 # Should be None unless modal mode
                 message,                # Alias for user prompt output
                 caption=wx.EmptyString, # Alias for title
                 value=wx.EmptyString,   # Option for default user input
                 style=wx.TEXT_ENTRY_DIALOG_STYLE, # Options for ClientRect
                 size=wx.DefaultSize,    # Extension for application use
                 pos=wx.DefaultPosition  # Option for application use
                 ):
        '''
        Use ShowModal() to show the dialog.

        Parameters:

        parent  Parent window.

        message Message to show on the dialog.

        caption The caption of the dialog.

        value   The default value, which may be the empty string.

        style   A dialog style, specifying the buttons (wxOK, wxCANCEL)
                and an optional wxCENTRE style. Additionally, wxTextCtrl
                styles (such as wxTE_PASSWORD or wxTE_MULTILINE) may be
                specified here.

        pos     Dialog position.
        '''
        theClass = 'TextEntryDialog'

        # Capture initial caller parametsrs before Dialog makes changes
        self.backup_parent = parent
        self.backup_message = message
        self.backup_caption = caption
        self.backup_value = value
        self.backup_style = style
        self.backup_size = size
        self.backup_pos = pos

        name = wx.TextEntryDialogNameStr
        title = caption
        self.backup_name = name
        self.backup_size = size
        self.backup_title = title

        # Capture initial caller parametsrs before they are changed
        self.caller_caption = caption
        self.caller_message = message
        self.caller_name = name
        self.caller_parent = parent
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_title = title
        self.caller_value = value

        wx.RegisterFirstCallerClassName(self, theClass)

        Dialog.__init__(self,
                        parent, # self.GetParentForModalDialog(parent, style),
                        id=wx.ID_ANY,
                        title=title,
                        pos=pos,
                        size=size,
                        # Apply Default Dialog Style to Top-Level Window
                        # (defer TextEntryDialog style for internal layout)
                        style=wx.DEFAULT_DIALOG_STYLE,
                        name=name)

        # Capture parameters.
        self.ts_Caption = self.backup_caption
        self.ts_Message = self.backup_message
        self.ts_Parent = self.backup_parent    # Should be None unless modal mode
        self.ts_Pos = self.backup_pos
        self.ts_Size = self.backup_size
        self.ts_Style = self.backup_style
        self.ts_Title = self.backup_title
        self.ts_Value = self.backup_value

        self.ts_Completion = False
        self.ts_PasswordMode = False
        self.ts_StripSpaces = False

##        (self.ts_Rect,
##         self.ts_ClientRect) = self.tsTextEntryDialogLayout(
##             parent, pos, size, style, caption)

        thePosition = self.Position
        theSize = self.Size

        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('              title: %s' % title)
            self.logger.debug('                pos: %s' % thePosition)
            self.logger.debug('               size: %s' % theSize)
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Name = name
        self.ts_Parent = parent

        if True:
            self.ts_BackgroundColour = wx.ThemeToUse[
                'TextEntryDialog']['BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'TextEntryDialog']['ForegroundColour'].lower()
        else:
            self.ts_BackgroundColour = wx.ThemeToUse[
                'Dialog']['BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'Dialog']['ForegroundColour'].lower()

        self.ts_ButtonSeparatorLine = wx.ThemeToUse[
            'TextEntryDialog']['ButtonSeparatorLine']

        self.ts_TextEntryStripSpaces = wx.ThemeToUse[
            'TextEntryDialog']['StripSpaces']

        self.ts_TextPad = None
        self.ts_IdleTimeQueue = wxDoubleLinkedList(lifoMode=False)
        self.ts_RealTimeQueue = wxDoubleLinkedList(lifoMode=False)

        self.ts_DescendantOrderOfShow = [self.ts_AssignedId]

        # The following redefines the usage of the style wx.CENTRE.
        # Intended only to govern the alignment of the buttons within
        # the dialog, we also apply it the centering of the dialog
        # itself within the desktop because the layout process cannot
        # wait for the application to initiate centering.
        if (self.ts_Style & wx.CENTRE) == wx.CENTRE:

            if DEBUG:

                msg = 'tsWxTextEntryDialog.__init__: ' + \
                      'Proceeding with tsDialogFeatureLayout. ' + \
                      'Style contains wx.CENTRE.'
                self.logger.debug(msg)
                print('DEBUG: %s\n' % msg)

            self.Center()

            self.theButtons = None
            self.theCancelButton = None
            self.theLine = None
            self.theMessage = None
            self.theOkButton = None
            self.theSpacer = None
            self.theTextBox = None
            self.theValue = None

            self.ts_TextPad = self.tsDialogFeatureLayout()

            self.Show()

        else:

            msg = 'tsWxTextEntryDialog.__init__: ' + \
                  'Skipped tsDialogFeatureLayout. ' + \
                  'Style did NOT contain wx.CENTRE.'
            self.logger.error(msg)
            print('ERROR: %s\n' % msg)

        self.ts_ButtonUserPressed = wx.ID_CANCEL

        self.tsEndClassRegistration(theClass)
コード例 #2
0
    def __init__(self,
                 parent,                 # Should be None unless modal mode
                 message,                # Alias for user prompt output
                 caption=wx.EmptyString, # Alias for title
                 value=wx.EmptyString,   # Option for default user input
                 style=wx.TEXT_ENTRY_DIALOG_STYLE, # Options for ClientRect
                 size=wx.DefaultSize,    # Extension for application use
                 pos=wx.DefaultPosition  # Option for application use
                 ):
        '''
        '''
        theClass = 'TextEntry'

        # Capture initial caller parametsrs before they are changed
        self.caller_caption = caption
        self.caller_message = message
        self.caller_name = name
        self.caller_parent = parent
        self.caller_pos = pos
        self.caller_size = size
        self.caller_style = style
        self.caller_title = title
        self.caller_value = value

##        wx.RegisterFirstCallerClassName(self, theClass)

##        Dialog.__init__(self,
##                        parent, # self.GetParentForModalDialog(parent, style),
##                        id=wx.ID_ANY,
##                        title=title,
##                        pos=pos,
##                        size=size,
##                        # Apply Default Dialog Style to Top-Level Window
##                        # (defer TextEntryDialog style for internal layout)
##                        style=wx.DEFAULT_DIALOG_STYLE,
##                        name=name)

        # Capture parameters.
        self.ts_Caption = self.backup_caption
        self.ts_Message = self.backup_message
        self.ts_Parent = self.backup_parent    # Should be None unless modal mode
        self.ts_Pos = self.backup_pos
        self.ts_Size = self.backup_size
        self.ts_Style = self.backup_style
        self.ts_Title = self.backup_title
        self.ts_Value = self.backup_value

##        (self.ts_Rect,
##         self.ts_ClientRect) = self.tsTextEntryDialogLayout(
##             parent, pos, size, style, caption)

        thePosition = self.Position
        theSize = self.Size

        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('              title: %s' % title)
            self.logger.debug('                pos: %s' % thePosition)
            self.logger.debug('               size: %s' % theSize)
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Name = name
        self.ts_Parent = parent

        if True:
            self.ts_BackgroundColour = wx.ThemeToUse[
                'TextEntryDialog']['BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'TextEntryDialog']['ForegroundColour'].lower()
        else:
            self.ts_BackgroundColour = wx.ThemeToUse[
                'Dialog']['BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'Dialog']['ForegroundColour'].lower()

        self.ts_TextPad = None
        self.ts_IdleTimeQueue = wxDoubleLinkedList(lifoMode=False)
        self.ts_RealTimeQueue = wxDoubleLinkedList(lifoMode=False)

        self.ts_DescendantOrderOfShow = [self.ts_AssignedId]

        # The following redefines the usage of the style wx.CENTRE.
        # Intended only to govern the alignment of the buttons within
        # the dialog, we also apply it the centering of the dialog
        # itself within the desktop because the layout process cannot
        # wait for the application to initiate centering.
        if (self.ts_Style & wx.CENTRE) == wx.CENTRE:

            if DEBUG:

                msg = 'tsWxTextEntryDialog.__init__: ' + \
                      'Proceeding with tsDialogFeatureLayout. ' + \
                      'Style contains wx.CENTRE.'
                self.logger.debug(msg)
                print('DEBUG: %s\n' % msg)

            self.Center()

            self.ts_TextPad = self.tsDialogFeatureLayout()

            self.Show()

        else:

            msg = 'tsWxTextEntryDialog.__init__: ' + \
                  'Skipped tsDialogFeatureLayout. ' + \
                  'Style did NOT contain wx.CENTRE.'
            self.logger.error(msg)
            print('ERROR: %s\n' % msg)

        self.ts_ButtonUserPressed = wx.ID_CANCEL

        self.tsEndClassRegistration(theClass)
コード例 #3
0
    def __init__(self):
        """
        Create a new application object, starting the bootstrap process.
        """

        theClass = "PyApp"

        wx.RegisterFirstCallerClassName(self, theClass)

        # Initiate bootstrap process

        EvtHandler.__init__(self)

        applicationId = wx.ID_ANY

        self.tsBeginClassRegistration(theClass, applicationId)

        self.ts_theTerminal = tsGTUI.GraphicalTextUserInterface(theClass)
        try:
            if True:
                PyApp._TheGeometry = self.ts_theTerminal.StdscrGeometryPixels
            else:
                (theScreenX, theScreenY, theScreenWidth, theScreenHeight) = self.ts_theTerminal.StdscrGeometry

                PyApp._TheGeometry = wxRect(
                    theScreenX * wx.pixelWidthPerCharacter,
                    theScreenY * wx.pixelHeightPerCharacter,
                    theScreenWidth * wx.pixelWidthPerCharacter,
                    theScreenHeight * wx.pixelHeightPerCharacter,
                )

        except AttributeError:
            PyApp._TheGeometry = wxRect(-1, -1, -1, -1)

        self.ts_Active = True
        self.ts_AppName = None
        self.ts_AssertMode = False
        self.ts_ClassName = theClass
        self.ts_EventLoop = None
        self.ts_Exit = False
        self.ts_ExitMainLoop = False
        self.ts_ExitOnFrameDelete = True
        self.ts_IdleEvents = False
        self.ts_IsActive = False
        self.ts_LayoutDirection = wx.Layout_Default

        self.ts_PrintMode = wx.UseDefaultValue

        ##        self.ts_thisown = None

        # Create a Frame that encompasses entire curses screen (stdscr).
        # It is the default for handling mouse clicks outside of those
        # top-level windows (frames and dialogs), and their children,
        # that do not fully occupy the curses screen.
        theParent = None
        self.ts_TheTopUserWindow = None
        self.ts_TheTopWindow = wxScreen(
            theParent,
            id=wx.ID_ANY,
            title="Screen",
            pos=wx.DefaultPosition,
            size=wx.DefaultSize,
            style=wx.DEFAULT_FRAME_STYLE,
            name=wx.ScreenNameStr,
        )

        # Set default Window that will receive Keyboard Text Entry Input.
        # Must bypass use of self.tsRegisterKeyboardInputOrder()
        try:

            tsWxGTUI_DataBase.KeyboardInputRecipients["lifoList"] = self.ts_TheTopWindow

        except Exception as errorCode:

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

        self.ts_Traits = None
        self.ts_UseBestVisual = True
        self.ts_VendorName = wx.ThemeToUse["VendorName"]

        if wx.ThemeToUse["TaskBar"]["Enable"]:
            self.ts_TaskWin = self.tsCreateTaskBar()
            self.ts_TaskWin.Show()
            self.ts_TaskWin.tsShowTaskBar()
        else:
            self.ts_TaskWin = None

        # Set True for Event Handling
        PyApp._KeepGoing = True
        PyApp._OnExitCompleted = False
        self.ts_IdleQueue = wxDoubleLinkedList()

        self.logger.debug("tsWxPyApp.keepGoing: %s for %s (0x%X)." % (PyApp._KeepGoing, theClass, id(self)))

        PyApp.ts_WxApp = self

        ##        self.ts_BootstrapApp()

        self.tsEndClassRegistration(theClass)
コード例 #4
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title=wx.EmptyString,
                 pos=wx.DefaultPosition,
                 size=wx.DefaultSize,
                 style=wx.DEFAULT_DIALOG_STYLE,
                 name=wx.DialogNameStr):
        '''
        '''
        theClass = 'Dialog'

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

        wx.RegisterFirstCallerClassName(self, theClass)

        TopLevelWindow.__init__(self)

        self.tsBeginClassRegistration(theClass, id)

        self.ts_oldFocus = None
        self.ts_isShown = False
        self.ts_modalData = None
        self.ts_endModalCalled = False
        self.ts_dialogToolBar = None

        self.ts_ButtonSizerFlags = 32926
        self.ts_returnCode = 0
        self.ts_sizeSet = False
        self.ts_modalShowing = False
        self.ts_themeEnabled = True

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

        thePosition = self.Position
        theSize = self.Size

        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('              title: %s' % title)
            self.logger.debug('                pos: %s' % thePosition)
            self.logger.debug('               size: %s' % theSize)
            self.logger.debug('              style: 0x%X' % style)
            self.logger.debug('               name: %s' % name)

        self.ts_Name = name
        self.ts_Parent = parent

        self.ts_IdleTimeQueue = wxDoubleLinkedList(lifoMode=False)
        self.ts_RealTimeQueue = wxDoubleLinkedList(lifoMode=False)

        self.ts_DescendantOrderOfShow = [self.ts_AssignedId]

        theTopLevelClass = self
        self.SetTopLevelAncestor(theTopLevelClass)

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

        if True:
            self.ts_BackgroundColour = wx.ThemeToUse[
                'Dialog']['BackgroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'Dialog']['ForegroundColour'].lower()
        else:
            self.ts_BackgroundColour = wx.ThemeToUse[
                'ForegroundColour'].lower()
            self.ts_ForegroundColour = wx.ThemeToUse[
                'BackgroundColour'].lower()

##        self.ts_FocusEnabled = True
        self.SetFocus()

        self.ts_Label = title
        self.ts_Style = style
        self.ts_Title = title

        self.ts_defaultDialogAcceleratorEntries = {
            '?': {'name': 'OnHelp',
                  'flags': wx.ACCEL_ALT,
                  'keyCode': ord('?'),
                  'cmdID': wx.ID_ANY},
            'X': {'name': 'OnClose',
                  'flags': wx.ACCEL_ALT,
                  'keyCode': ord('X'),
                  'cmdID': wx.ID_ANY}
            }

        # 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)