2011-07-19 40 views
1

我的可摺疊窗格出現問題。展開/摺疊功能起作用。但我無法點擊我的擴展按鈕或文本框。窗格顯示我的內容,但不可點擊。控件在我的可摺疊窗格中不可點擊(wxPython)

我使用明確的位置座標嗎?(但我故意這樣做了。) 是這個原因嗎?

下面的例子:(你會看到擴展按鈕,但你不能按他們)

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

回答

1

我覺得父母參數不正確。 編輯這一行:

subpanel = wxPanel(self, 0) 

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

,也將努力;)