I'm a wxPython beginner, and I'm having a problem using wxSplitter. I'm sure I'm just missing some simple piece of initialization -- perhaps someone can help?
My problem is that when I put a control (or whatever) inside a splitter it isn't "active" (ie, doesn't respond to user input). Here's a sample program which demonstrates my problem:
---------- <code> ----------
from wxPython.wx import *
class MainWindow(wxFrame):
def __init__(self, parent, id, title):
# --------- Call Parent Init -----------
wxFrame.__init__(self, parent, -1, title)
# --------- Create Pane Contents -----------
TEST_TO_RUN = 1
if TEST_TO_RUN == 0:
self.mainPane = wxButton(self, id=-1, label="Click Me")
mainWindowContents = self.mainPane
elif TEST_TO_RUN == 1:
splitter = wxSplitterWindow(self, -1)
self.leftPane = wxButton(self, id=-1, label="Left")
self.rightPane = wxButton(self, id=-1, label="Right")
splitter.SplitVertically(self.leftPane, self.rightPane)
splitter.SetSashPosition(200)
splitter.SetMinimumPaneSize(20)
mainWindowContents = splitter
# -- mainWindowContents fills the window --
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(mainWindowContents, 1, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(true)
# --------- Set Up Window Events -----------
EVT_CLOSE(self, self.onCloseWindow)
# --------- Show the frame -----------
self.Show(true)
def onCloseWindow(self, event):
self.Destroy()
class App(wxApp):
def OnInit(self):
frame = MainWindow(None, -1, 'Title')
self.SetTopWindow(frame)
return true
if __name__ == '__main__':
app = App(0)
app.MainLoop()
---------- </code> ----------
To test this, set TEST_TO_RUN to 0, and observe that the button which is created can be "clicked". Then change it to 1, and the two buttons created will NOT react when clicked.
What's the simple bit of initialization that I'm ommitting?
-- Michael Chermside