I learned today about collapsible panes. But I can't get it to work. the error I get is:
"TypeError: in method 'new_CollapsiblePane', expected argument 1 of type 'wxWindow *'"
I tried to have the collapsible filter as a "def", as a class and included in the class main. And now I am out of ideas.
This is my most recent code:
class Main(wx.Panel):
def __init__(self, parent=None, id=-1, notify_channel=None, **kwargs):
wx.Panel.__init__(self, parent, id)
"some other stuff"
self.rightsizer.AddStretchSpacer(1)
self.rightsizer.Add(self.listsizer, 80, wx.EXPAND)
self.rightsizer.AddStretchSpacer(1)
self.sizer.AddStretchSpacer(1)
self.sizer.Add(CollapsibleFilter(self, label="Filter:"), 0, wx.EXPAND)
self.sizer.AddStretchSpacer(1)
self.sizer.Add(self.rightsizer, 50, wx.EXPAND)
self.sizer.AddStretchSpacer(2)
self.SetSizer(self.sizer)
self.sizer.Fit(self)
class CollapsibleFilter(wx.CollapsiblePane):
def __init__(self, notify_channel, **kwargs):
wx.CollapsiblePane.__init__(self,wx.ID_ANY, **kwargs)
self.notify_channel = notify_channel
self.CollapsibleFilter=self.GetPane()
self.filter1 = FilterBox(self.CollapsibleFilter, notify_channel=self.notify_channel)
self.filter2 = FilterBox(self.CollapsibleFilter, notify_channel=self.notify_channel)
self.filter3 = FilterBox(self.CollapsibleFilter, notify_channel=self.notify_channel)
self.filter1.set_dropdown_items(browser_options.filterlist)
self.filter1.set_dropdown_default(browser_options.default_1)
self.filter2.set_dropdown_items(browser_options.filterlist)
self.filter2.set_dropdown_default(browser_options.default_2)
self.filter3.set_dropdown_items(browser_options.filterlist)
self.filter3.set_dropdown_default(browser_options.default_3)
#layout
self.filtersizer = wx.BoxSizer(wx.VERTICAL)
self.filtersizer.AddStretchSpacer(1)
self.filtersizer.Add(self.filter1, 60, wx.EXPAND)
self.filtersizer.AddStretchSpacer(1)
self.filtersizer.Add(self.filter2, 60, wx.EXPAND)
self.filtersizer.AddStretchSpacer(1)
self.filtersizer.Add(self.filter3, 60, wx.EXPAND)
self.filtersizer.AddStretchSpacer(1)
I hope someone can help me! Tx
Just like any widget class it needs to receive a reference to the parent widget when constructed. In your CollapsibleFilter
class, when it calls the super class __init__
you are not passing a parent, so that is why it is failing. Try this:
class CollapsibleFilter(wx.CollapsiblePane):
def __init__(self, parent, notify_channel, **kwargs):
wx.CollapsiblePane.__init__(self, parent, wx.ID_ANY, **kwargs)
...