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 print('Automatic Positioning & Sizing for expected layout.') boxHorizontal = wx.BoxSizer(wx.HORIZONTAL) panel1 = wx.Panel(parent, wx.ID_ANY, style=wx.BORDER_SIMPLE) panel2 = wx.Panel(parent, wx.ID_ANY, style=wx.BORDER_SIMPLE) panel1.SetBackgroundColour("MAGENTA") panel2.SetBackgroundColour("RED") boxHorizontal.Add(panel1, proportion=2, flag=wx.EXPAND) # TBD - Resolve why the following disrupt boxHorizontal display ## boxHorizontal.AddSpacer(8) ## boxHorizontal.AddSpacer(wx.SizerSpacer((wx.pixelWidthPerCharacter, ## wx.pixelHeightPerCharacter)) boxHorizontal.Add(panel2, proportion=1, flag=wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(boxHorizontal) self.Layout() self.Show(show=True) boxVertical = wx.BoxSizer(wx.VERTICAL) panel3 = wx.Panel(panel1, wx.ID_ANY, style=wx.BORDER_SIMPLE) panel4 = wx.Panel(panel1, wx.ID_ANY, style=wx.BORDER_SIMPLE) panel5 = wx.Panel(panel1, wx.ID_ANY, style=wx.BORDER_SIMPLE) panel3.SetBackgroundColour("CYAN") panel4.SetBackgroundColour("GREEN") panel5.SetBackgroundColour("YELLOW") boxVertical.Add(panel3, proportion=1, flag=wx.EXPAND) boxVertical.Add(panel4, proportion=1, flag=wx.EXPAND) boxVertical.Add(panel5, proportion=1, flag=wx.EXPAND) panel1.SetAutoLayout(True) panel1.SetSizer(boxVertical) 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()))
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=((280 * 3) / 3, (200 * 3) / 3), 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='GridSizer') #------------------------------------------------------------------- # 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. ## 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 print('Automatic Positioning & Sizing for expected layout.') boxVerticalFlag = wx.EXPAND boxVertical = wx.BoxSizer(wx.VERTICAL) boxVerticalPanel = wx.Panel(parent, wx.ID_ANY, style=wx.BORDER_SIMPLE) boxVerticalPanel.SetBackgroundColour("MAGENTA") boxVertical.Add(boxVerticalPanel, proportion=1, flag=boxVerticalFlag) boxVerticalPanel.SetAutoLayout(True) boxVerticalPanel.SetSizer(boxVertical) boxVerticalPanel.Layout() self.Show(show=True) nRows = 5 # 5 nCols = 4 # 4 vGap = 5 # 5 hGap = 5 # 5 gsFlag = wx.ALIGN_CENTER_HORIZONTAL | \ wx.ALIGN_CENTER_VERTICAL # wx.EXPAND gs = wx.GridSizer(nRows, nCols, vGap, hGap) gs.AddMany( [ ## (wx.Button(boxVerticalPanel, label='Cls'), 0, gsFlag), ## (wx.Button(boxVerticalPanel, label='Bck'), 0, gsFlag), ## (wx.StaticText(boxVerticalPanel), 0, gsFlag), ## (wx.Button(boxVerticalPanel, label='Close'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='7'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='8'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='9'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='/'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='4'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='5'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='6'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='*'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='1'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='2'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='3'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='-'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='0'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='.'), 0, gsFlag), (wx.Button(boxVerticalPanel, label='='), 0, gsFlag), (wx.Button(boxVerticalPanel, label='+'), 0, gsFlag) ]) boxVertical.Add(gs, proportion=1, flag=gsFlag) boxVerticalPanel.SetSizer(gs) gs.Layout() theFrame.Show(show=True) self.Show(show=True) 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=(40 * wx.pixelWidthPerCharacter, 10 * 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 # 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.notice( 'Begin %s (0x%X).' % ('Prototype', self.tsGetTheId())) print( 'Begin %s (0x%X).' % ('Prototype', self.tsGetTheId())) #------------------------------------------------------------------- # Begin Prototype #------------------------------------------------------------------- self.Centre() self.Show() theFrame = self theRect = theFrame.Rect theClientArea = theFrame.ClientArea print('Frame: Rect=%s; ClientArea=%s' % (str(theRect), str(theClientArea))) theText = "Hello, World! " print("theText=%s" % theText) # Allow additional width for cursor theTextWidth = (len(theText) + 1) * wx.pixelWidthPerCharacter theTextHeight = 1 * wx.pixelHeightPerCharacter theTextOffset = wx.Point( (theClientArea.x + ( (theClientArea.width - theTextWidth) // 2)), (theClientArea.y + ( (theClientArea.height - theTextHeight) // 2))) print("theTextOffset=%s" % str(theTextOffset)) theTextSize = wx.Size(theTextWidth, theTextHeight) print("theTextSize=%s" % str(theTextSize)) text = wx.StaticText( theFrame, pos=theTextOffset, size=theTextSize, label=theText) 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()))