import wx # wx.Frame(parent, id=ID_ANY, title=EmptyString, pos=DefaultPosition, size=DefaultSize, style=DEFAULT_FRAME_STYLE, name=FrameNameStr) # wx.Panel(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=TAB_TRAVERSAL, name=PanelNameStr) # wx.TextCtrl(parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=TextCtrlNameStr) class Frame_With_FrameSizer_And_PanelSizer(wx.Frame): def __init__(self, parent, id=wx.ID_ANY, title=wx.EmptyString, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE, name=wx.FrameNameStr): wx.Frame.__init__(self, parent, id, title, pos, size, style, name) self.MainPanel = wx.Panel(self) self.mainTextSubWindow = wx.TextCtrl(self.MainPanel, style=wx.TE_MULTILINE ) # Layout # The textctrl is a child of the panel, not the frame. # So add the textctrl to a sizer that is an attribute of the panel, not of the frame # This sizer is necessary if the panel widget, has more then one child widget. # In general I always do it anyway. panel_sizer = wx.BoxSizer(wx.VERTICAL) panel_sizer.Add(self.mainTextSubWindow, 1, wx.EXPAND) self.MainPanel.SetSizer(panel_sizer) # This sizer is necessary if the frame widget, has more then one child widget, # In general I always do it anyway. frame_sizer = wx.BoxSizer(wx.VERTICAL) frame_sizer.Add(self.MainPanel, 1, wx.EXPAND) self.SetSizer(frame_sizer) self.Show() if __name__ == "__main__": app = wx.App() frame = Frame_With_FrameSizer_And_PanelSizer(None, title='Frame Sizer plus Panel Sizer') app.MainLoop()