You just need to to call Layout() on your sizer object:
import wx
import p
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Checking Menubar from external Panel")
mainPanel = wx.Panel(self, -1)
mainPanel.SetBackgroundColour(wx.Color(0, 255, 0))
sizer = wx.BoxSizer(wx.VERTICAL)
mainPanel.SetSizer(sizer)
subPanel = p.MyPanel(parent=mainPanel)
sizer.Add(subPanel, 1, wx.EXPAND)
# subPanel.createMenuBar()
self.Show()
sizer.Layout()
if __name__ == '__main__':
app = wx.App(False)
frame = MyFrame()
app.MainLoop()
Personally, I don't really see a reason to add a single panel on top of another panel. That just adds unneeded complexity. Here's a shorter version:
import wx
import p
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "Checking Menubar from external Panel")
sizer = wx.BoxSizer(wx.VERTICAL)
mainPanel = p.MyPanel(parent=self)
sizer.Add(mainPanel, 1, wx.EXPAND)
self.SetSizer(sizer)
self.Show()
if __name__ == '__main__':
app = wx.App(False)
frame = MyFrame()
app.MainLoop()
You will note that I don't need to even call Layout() on this second version because theirs only one panel and it automatically takes up all the space. Also note that I changed your call from wx.PySimpleApp to wx.App(False). PySimpleApp is deprecated.