BoxSizer in Frame and Panel
Question: When i create a BoxSizer like this:

    
    
    class MyForm(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, wx.ID_ANY, 
                          "App",size=(800,600),style= wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.CLOSE_BOX)
            self.panel=wx.Panel(self,size=(800,600))
            # create BoxSizer and fill it with elements
    

it works. But when I do this:

    
    
    class MyForm(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, wx.ID_ANY, 
                          "App",size=(800,600),style= wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.CLOSE_BOX)
            panelThree(self)
    
    class panelThree(wx.Panel):
        def __init__(self, parent):
            wx.Panel.__init__(self, parent=parent,size=(800,600))
            self.panel=wx.Panel(self,size=(800,600))
            # create BoxSizer and fill it with elements
    

then something goes wrong: all elements are located in the top left corner and
they overlap each other. How do I have to use BoxSizer when I want to use it
in my class _panelThree_ ? I just took the example from here:
<http://wiki.wxpython.org/BoxSizerTutorial>


Answer: The problem is most likely that you are not adding the following widget to the
sizer: self.panel. If you do not add it to the sizer, then it's going to mess
up your layout. Personally, I don't think you even need a panel inside a
panel. Removing that line will fix the issue:

    
    
    import wx
    
    class MyForm(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, wx.ID_ANY, 
                          "App",size=(800,600),style= wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.CLOSE_BOX)
            panelThree(self)
    
    class panelThree(wx.Panel):
        def __init__(self, parent):
            wx.Panel.__init__(self, parent=parent,size=(800,600))
            self.panel=wx.Panel(self,size=(800,600))
            # create BoxSizer and fill it with elements
            sizer = wx.BoxSizer(wx.VERTICAL)
    
            for item in range(10):
                btn = wx.Button(self, label="Button %s" % item)
                sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
    
            self.SetSizer(sizer)
    
    #----------------------------------------------------------------------
    if __name__ == "__main__":
        app = wx.App(False)
        frame = MyForm()
        frame.Show()
        app.MainLoop()
    

