Skip to content Skip to sidebar Skip to footer

Wxpython Collapsiblepane Strange Clipping Issue

This is a follow up from allocating more size in sizer to wx.CollapsiblePane when expanded. EDIT: The answer to that question solved my original problem, which was that nothing mo

Solution 1:

If I am getting you right, you want the code here - allocating more size in sizer to wx.CollapsiblePane when expanded to work properly. The reason it did not work was you forgot to bind the wx.EVT_COLLAPSIBLEPANE_CHANGED. Here is a code which worked for me -

import wx

class SampleCollapsiblePane(wx.CollapsiblePane):
    def __init__(self, *args, **kwargs):
        wx.CollapsiblePane.__init__(self,*args,**kwargs)
        sizer = wx.BoxSizer(wx.VERTICAL)

        for x in range(5):
            sizer.Add(wx.Button(self.GetPane(), label = str(x)))

        self.GetPane().SetSizer(sizer)
        self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED, self.on_change)

    def on_change(self, event):
        self.GetParent().Layout()

class Main_Frame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.main_panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)

        for x in range(5):
            sizer.Add(SampleCollapsiblePane(self.main_panel, label = str(x)), 0)

        self.main_panel.SetSizer(sizer)


class SampleApp(wx.App):
    def OnInit(self):
        frame = Main_Frame(None, title = "Sample App")
        frame.Show(True)
        frame.Centre()
        return True

def main():
    app = SampleApp(0)
    app.MainLoop()

if __name__ == "__main__":
    main()

EDIT: Looks like it may be a bug in wxPython running on windows. Below is screen shot of the the exact same code that has problems on Windows running on Ubuntu with no problems. enter image description here

Post a Comment for "Wxpython Collapsiblepane Strange Clipping Issue"