I'm creating a panel for a notebook, and I need to add a sizer. However, when I run my code:
class HomePanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent)
[...Widget Code...]
self.verticalsizer = wx.BoxSizer(wx.VERTICAL)
self.verticalsizer.AddStretchSpacer(prop=1)
self.verticalsizer.Add(self.text, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=30)
self.verticalsizer.Add(self.text1, flag=wx.ALIGN_CENTER | wx.BOTTOM, border=20)
self.verticalsizer.AddStretchSpacer(prop=1)
HomePanel.SetSizer(self.verticalsizer)
HomePanel.Layout()
I get a typeerror regarding line the SetSizer():
TypeError: unbound method SetSizer() must be called with HomePanel instance as first argument (got BoxSizer instance instead)
I'm not sure what else I could assign the SetSizer() to, but since this won't work either I'm stuck. Is there a way to get around this or do it better?
Instead of:
HomePanel.SetSizer(self.verticalsizer)
HomePanel.Layout()
Use self:
self.SetSizer(self.verticalsizer)
self.Layout()