def main(self): ''' Get a wx App Build the communicate Frame Enter wx main loop ''' app = wx.PySimpleApp(redirect=True, filename=None) frame = wx.Frame(None, title='Hello World') frame.Show() message = 'Started timestamped wxPython: stdout/stderr\n\n' + \ 'Print statements and other standard output ' + \ 'will now be directed to this window.' self.theWindowLogger.info(message) self.theWindowLogger.debug('Before MainLoop') parent = frame baseLabel = 'Greetings!' baseStyle = 0 # wx.BORDER_SIMPLE baseCol = 5 baseRow = 10 basePos = wx.tsGetPixelValues(baseCol, baseRow) if baseStyle == 0: baseSize = wx.tsGetPixelValues(len(baseLabel) + 1, 1) else: baseSize = wx.tsGetPixelValues(len(baseLabel) + 4, 1 + 2) junk = wxStaticText( parent, id=wx.ID_ANY, label=baseLabel, pos=basePos, size=baseSize, style=baseStyle, validator=wx.DefaultValidator, name=wx.StaticTextNameStr) junk.Show() print("Before MainLoop") app.MainLoop() print("After MainLoop") self.theWindowLogger.debug('After MainLoop')
def __init__( self, parent, id=nextWindowId(), title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr, ): """ Init the Frame Show the Frame """ if False and frameSizingEnabled: wx.Frame.__init__( self, parent, id=nextWindowId(), title=title, pos=pos, size=((280 * 4) / 2, (200 * 4) / 2), style=style, name=name, ) else: # Establish character and pixel position of this canvas # Set at top left row and column of area to be centered, by # default, in the user terminal screen. begin_y = -1 begin_x = -1 thePos = wx.tsGetPixelValues(begin_x, begin_y) # Establish character and pixel size of this canvas # for the wxPython application "tsWxGUI_test1.py". # # VGA Display (640 x 480 pixels) with Courier (8 x 12 pixels) # monospaced font characters contains (80 Cols x 40 Rows). # Set typical console area max_x = -1 # 80 max_y = -1 # 30 theSize = wx.tsGetPixelValues(max_x, max_y) wx.Frame.__init__( self, parent, id, name="Frame", title=title, pos=thePos, size=theSize, style=wx.DEFAULT_FRAME_STYLE ) # Cannot log before GUI started via Frame. self.logger.debug("Begin %s (0x%X)." % ("Prototype", self.tsGetTheId())) # ------------------------------------------------------------------- # Begin Prototype # ------------------------------------------------------------------- # TBD - Menu Bar Client Area Change in Frame did not # reduce height of panel. theFrame = self menubar = wx.MenuBar(theFrame) fileMenu = wx.Menu() menubar.Append(fileMenu, "&File") self.SetMenuBar(menubar) self.Centre() self.Show() theRect = theFrame.Rect theClientArea = theFrame.ClientArea print("Frame: Rect=%s; ClientArea=%s" % (str(theRect), str(theClientArea))) self.TestScrolled(theFrame) self.Show() # ------------------------------------------------------------------- # End Prototype # ------------------------------------------------------------------- self.logger.debug("End %s (0x%X)." % ("Prototype", self.tsGetTheId()))
def __init__(self, parent, id=nextWindowId(), title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr): ''' Init the Frame Show the Frame ''' if frameSizingEnabled: wx.Frame.__init__(self, parent, id=nextWindowId(), title=title, pos=pos, size=((83 * wx.pixelWidthPerCharacter), (70 * wx.pixelHeightPerCharacter)), style=style, name=name) # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA else: # Establish character and pixel position of this canvas # Set at top left row and column of area to be centered, by # default, in the user terminal screen. begin_y = -1 begin_x = -1 thePos = wx.tsGetPixelValues(begin_x, begin_y) # Establish character and pixel size of this canvas # for the wxPython application "tsWxGUI_test1.py". # # VGA Display (640 x 480 pixels) with Courier (8 x 12 pixels) # monospaced font characters contains (80 Cols x 40 Rows). # Set typical console area max_x = -1 # 300 max_y = -1 # 250 theSize = wx.tsGetPixelValues(max_x, max_y) wx.Frame.__init__( self, parent, id, name='Frame', title=title, pos=thePos, size=theSize, style=wx.DEFAULT_FRAME_STYLE) # Cannot log before GUI started via Frame. self.logger.debug( 'Begin %s (0x%X).' % ('Prototype', self.tsGetTheId())) # The following tests depend on Showing final Frame position. ## if splashScreenEnabled: ## self.theSplashScreen.tsShow() ## time.sleep(splashScreenSeconds) ## self.myframe = wx.Frame(None, title='FieldMarkup') #------------------------------------------------------------------- # Begin Frame Relocation #------------------------------------------------------------------- # TBD - Menu Bar Client Area Change in Frame did not # reduce height of panel. theFrame = self ## menubar = wx.MenuBar(theFrame) ## fileMenu = wx.Menu() ## menubar.Append(fileMenu, '&File') ## self.SetMenuBar(menubar) ## self.Centre() self.Show() theRect = theFrame.Rect theClientArea = theFrame.ClientArea print('Frame: Rect=%s; ClientArea=%s' % (str(theRect), str(theClientArea))) #------------------------------------------------------------------- # End Frame Relocation #------------------------------------------------------------------- #------------------------------------------------------------------- # Begin Prototype #------------------------------------------------------------------- # TBD - Menu Bar Client Area Change in Frame did not # reduce height of panel. parent = self self.InitUI(parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr) self.Show() theMarkupKeys = wx.ThemeToUse['StdioMarkup'].keys() for theKey in sorted(theMarkupKeys): ## for theKey in theMarkupKeys: theMarkup = wx.ThemeToUse['StdioMarkup'][theKey] theMarkupText = 'Logger Key is %s: with %s.\n' % ( theKey, str(theMarkup)) print(theMarkupText) self.logger.debug( 'End %s (0x%X).' % ('Prototype', self.tsGetTheId()))
def __init__(self, parent, id=nextWindowId(), title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr): ''' Init the Frame Show the Frame ''' if frameSizingEnabled: wx.Frame.__init__(self, parent, id=nextWindowId(), title=title, pos=pos, size=((280 * 3) / 2, (200 * 3) / 2), style=style, name=name) # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA else: # Establish character and pixel position of this canvas # Set at top left row and column of area to be centered, by # default, in the user terminal screen. begin_y = -1 begin_x = -1 thePos = wx.tsGetPixelValues(begin_x, begin_y) # Establish character and pixel size of this canvas # for the wxPython application "tsWxGUI_test1.py". # # VGA Display (640 x 480 pixels) with Courier (8 x 12 pixels) # monospaced font characters contains (80 Cols x 40 Rows). # Set typical console area max_x = -1 # 80 max_y = -1 # 30 theSize = wx.tsGetPixelValues(max_x, max_y) wx.Frame.__init__( self, parent, id, name='Frame', title=title, pos=thePos, size=theSize, style=wx.DEFAULT_FRAME_STYLE) # Cannot log before GUI started via Frame. self.logger.debug( 'Begin %s (0x%X).' % ('Prototype', self.tsGetTheId())) # The following tests depend on Showing final Frame position. ## if splashScreenEnabled: ## self.theSplashScreen.tsShow() ## time.sleep(splashScreenSeconds) ## self.myframe = wx.Frame(None, title='BoxSizer') #------------------------------------------------------------------- # Begin Prototype #------------------------------------------------------------------- # TBD - Menu Bar Client Area Change in Frame did not # reduce height of panel. theFrame = self menubar = wx.MenuBar(theFrame) fileMenu = wx.Menu() menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar) self.Centre() self.Show() theRect = theFrame.Rect theClientArea = theFrame.ClientArea print('Frame: Rect=%s; ClientArea=%s' % (str(theRect), str(theClientArea))) self.TestFileCommander(theFrame) #------------------------------------------------------------------- # End Prototype #------------------------------------------------------------------- # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA self.logger.debug( 'End %s (0x%X).' % ('Prototype', self.tsGetTheId()))
def __init__(self, parent, id=nextWindowId(), title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr): ''' Init the Frame Get a menubar Get a menu for the "file" menu Get a menu item for "Quit" Bind the "Quit" menu item to the method Add "Quit" to the "File" menu Add the "File" menu to the menubar Get a panel to cover the Frame TBD Needed? Create the "Right" panel Create the "Left" panel Get a box sizer - horizontal Add "Left" panel to box sizer Add "Right" panel to box sizer Set box sizer as sizer for the Frame panel Create Status bar Center the Frame Show the Frame ''' if frameSizingEnabled: wx.Frame.__init__(self, parent, id=nextWindowId(), title=title, pos=pos, size=(280, 200), style=style, name=name) # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA else: # Establish character and pixel position of this canvas # Set at top left row and column of area to be centered, by # default, in the user terminal screen. begin_y = -1 begin_x = -1 thePos = wx.tsGetPixelValues(begin_x, begin_y) # Establish character and pixel size of this canvas # for the wxPython application "tsWxGUI_test1.py". # # VGA Display (640 x 480 pixels) with Courier (8 x 12 pixels) # monospaced font characters contains (80 Cols x 40 Rows). # Set typical console area max_x = -1 # 80 max_y = -1 # 30 theSize = wx.tsGetPixelValues(max_x, max_y) wx.Frame.__init__( self, parent, id, name='Frame', title=title, pos=thePos, size=theSize, style=wx.DEFAULT_FRAME_STYLE) # Cannot log before GUI started via Frame. self.logger.debug( 'Begin %s (0x%X).' % ('Prototype', self.tsGetTheId())) # The following tests depend on Showing final Frame position. ## if splashScreenEnabled: ## self.theSplashScreen.tsShow() ## time.sleep(splashScreenSeconds) self.Show(show=True) # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA self.logger.debug( 'End %s (0x%X).' % ('Prototype', self.tsGetTheId()))
def __init__(self, parent, id=nextWindowId(), title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr): ''' Init the Frame Show the Frame ''' if frameSizingEnabled: wx.Frame.__init__(self, parent, id=nextWindowId(), title=title, pos=pos, size=((280 * 3) / 2, (200 * 3) / 2), style=style, name=name) # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA else: # Establish character and pixel position of this canvas # Set at top left row and column of area to be centered, by # default, in the user terminal screen. begin_y = -1 begin_x = -1 thePos = wx.tsGetPixelValues(begin_x, begin_y) # Establish character and pixel size of this canvas # for the wxPython application "tsWxGUI_test1.py". # # VGA Display (640 x 480 pixels) with Courier (8 x 12 pixels) # monospaced font characters contains (80 Cols x 40 Rows). # Set typical console area max_x = -1 # 80 max_y = -1 # 30 theSize = wx.tsGetPixelValues(max_x, max_y) wx.Frame.__init__( self, parent, id, name='Frame', title=title, pos=thePos, size=theSize, style=wx.DEFAULT_FRAME_STYLE) # Cannot log before GUI started via Frame. self.logger.debug( 'Begin %s (0x%X).' % ('Prototype', self.tsGetTheId())) # The following tests depend on Showing final Frame position. ## if splashScreenEnabled: ## self.theSplashScreen.tsShow() ## time.sleep(splashScreenSeconds) ## self.myframe = wx.Frame(None, title='BoxSizer') #------------------------------------------------------------------- # Begin Prototype #------------------------------------------------------------------- # TBD - Menu Bar Client Area Change in Frame did not # reduce height of panel. theFrame = self menubar = wx.MenuBar(theFrame) fileMenu = wx.Menu() menubar.Append(fileMenu, '&File') self.SetMenuBar(menubar) self.Centre() self.Show() theRect = theFrame.Rect theClientArea = theFrame.ClientArea print('Frame: Rect=%s; ClientArea=%s' % (str(theRect), str(theClientArea))) ## self.Show() # panel = wxPanel( # parent, # id=wx.ID_ANY, # pos=wx.DefaultPosition, # size=wx.DefaultSize, # style=wx.DEFAULT_PANEL_STYLE, # name=wx.PanelNameStr) parent = self logoPanel = wx.Panel( parent, id=wx.ID_ANY, ## pos=wx.Point(5 * wx.pixelWidthPerCharacter, ## 5 * wx.pixelHeightPerCharacter), ## size=wx.Size(10 * wx.pixelWidthPerCharacter, ## 10 * wx.pixelHeightPerCharacter), style=wx.DEFAULT_PANEL_STYLE, name=wx.PanelNameStr) print('Automatic Positioning & Sizing for expected layout.') boxVertical = wx.BoxSizer(wx.VERTICAL) panel1 = wx.Panel(logoPanel, wx.ID_ANY, # label=' t s ', style=wx.BORDER_DEFAULT) panel2 = wx.Panel(logoPanel, wx.ID_ANY, label=' G T U I ', style=wx.BORDER_DEFAULT) panel1.SetBackgroundColour("RED") panel1.SetForegroundColour("YELLOW") panel2.SetBackgroundColour("BLUE") panel2.SetForegroundColour("WHITE") boxVertical.Add(panel1, proportion=1, flag=wx.EXPAND) # TBD - Resolve why the following disrupt boxHorizontal display ## boxHorizontal.AddSpacer(8) ## boxHorizontal.AddSpacer(wx.SizerSpacer((wx.pixelWidthPerCharacter, ## wx.pixelHeightPerCharacter)) boxVertical.Add(panel2, proportion=1, flag=wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(boxVertical) self.Layout() self.Show(show=True) boxHorizontal = wx.BoxSizer(wx.HORIZONTAL) panel3 = wx.Panel(panel1, wx.ID_ANY, label=' t s ', style=wx.BORDER_DEFAULT) panel4 = wx.Panel(panel1, wx.ID_ANY, label=' W x ', style=wx.BORDER_DEFAULT) ## panel5 = wx.Panel(panel2, ## wx.ID_ANY, ## label='GTUI ', ## style=wx.BORDER_DEFAULT) panel3.SetBackgroundColour("RED") panel3.SetForegroundColour("YELLOW") panel4.SetBackgroundColour("GREEN") panel4.SetForegroundColour("BLUE") ## panel5.SetBackgroundColour("BLUE") ## panel5.SetForegroundColour("WHITE") boxHorizontal.Add(panel3, proportion=1, flag=wx.EXPAND) boxHorizontal.Add(panel4, proportion=1, flag=wx.EXPAND) panel1.SetAutoLayout(True) panel1.SetSizer(boxHorizontal) panel1.Layout() self.Show(show=True) #------------------------------------------------------------------- # End Prototype #------------------------------------------------------------------- # TBD - This should NOT change Frame color. # It should only change Panel color. ## self.ForegroundColour = wx.COLOR_YELLOW ## self.BackgroundColour = wx.COLOR_MAGENTA self.logger.debug( 'End %s (0x%X).' % ('Prototype', self.tsGetTheId()))