开发者

Controls are not clickable in my collapsible pane (wxPython)

开发者 https://www.devze.com 2023-03-21 02:03 出处:网络
I got a problem with my collapsible pane. The expand/collapse functionality works. But I can not click on my expanded buttons or textfields. The pane shows my content but it is not clickable.

I got a problem with my collapsible pane. The expand/collapse functionality works. But I can not click on my expanded buttons or textfields. The pane shows my content but it is not clickable.

I work with explicit position-coordinates?(But I did it on purpose.) Is that the reason?

Here an example: (You will see the expanded button but you can not click them)

from wxPython.wx import *
from wxPython.grid import *

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

        self.button =wx.Button(subpanel, label="Save", pos=(20, 170))
        self.Infotext = wx.StaticText(subpanel, -1, "this is a test", pos=(100, 174))
        self.Infotext.SetBackgroundColour((178,开发者_Go百科34,34)) 
        self.Infotext.SetForegroundColour((245, 245,220))       

        sizer.Add(subpanel)       

        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)

        sizer.Add(SampleCollapsiblePane(self.main_panel, label = str("Configurations")), 0,)
        sizer.Add(wx.Button(self.main_panel, label = str("the end")))

        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()


I think the parent parameter is incorrect. Edit this line:

subpanel = wxPanel(self, 0) 

in

subpanel = wxPanel(self.GetPane(), 0) 

and it will work ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消