why can't this wxPython frame (and a panel inside) keep its size?
Question: _**The background colour of panel is applied to the whole frame! why'd that be
happening, I wonder. Here, frame is (300,400) whereas the panel is supposed to
be (300,180). I might be doing something wrong._**

    
    
    #!/usr/bin/env python
    #-*- coding:utf-8 -*-
    
    import wx
    
    class Panel(wx.Panel):
        def __init__(self, parent, id, pos, size):
            wx.Panel.__init__(self, parent, id, pos, size) 
    
    class Frame(wx.Frame):
        def __init__(self, parent, id, title, pos, size, style):
            wx.Frame.__init__(self, parent, id, title, pos, size, style)
            self.userpanel = Panel(self, -1, (0,0), (300,180))
            self.userpanel.SetBackgroundColour('Gold')
    
    
    class Application(wx.App):
        def __init__(self):
            wx.App.__init__(self)
            frame = Frame(None, -1, "Internet Login Tool", (-1,-1), (300,400),\
            wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
            frame.Show()
            self.SetTopWindow(frame)
    
    if __name__ == '__main__':
        app = Application()
        app.MainLoop()
    


Answer: When you add a panel to a frame it takes up the whole area of the frame, add a
panel to the frame and then add your panel to the frames panel as shown in
your modified code below

    
    
    import wx
    
    class Panel(wx.Panel):
        def __init__(self, parent, id, pos, size):
            wx.Panel.__init__(self, parent, id, pos, size) 
    
    class Frame(wx.Frame):
        def __init__(self, parent, id, title, pos, size, style):
            wx.Frame.__init__(self, parent, id, title, pos, size, style)
            framePanel = wx.Panel(self)
            self.userpanel = Panel(framePanel, -1, (0,0), (300,180))
            self.userpanel.SetBackgroundColour('Gold')
    
    
    class Application(wx.App):
        def __init__(self):
            wx.App.__init__(self)
            frame = Frame(None, -1, "Internet Login Tool", (-1,-1), (300,400),\
            wx.DEFAULT_FRAME_STYLE ^ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
            frame.Show()
            self.SetTopWindow(frame)
    
    if __name__ == '__main__':
        app = Application()
        app.MainLoop()
    

