wxPython problem switching between 2 wx.SplitterWindow's

Dan Perl danperl at rogers.com
Fri Oct 8 16:29:45 CEST 2004


I have posted this problem also on the wxpython-users list, but maybe 
someone here can also help.

I want to keep 2 different views for the same object, both views using 
SplitterWindow.  So I am trying to create 2 SplitterWindow's, keeping both 
in memory, and alternately show only one of them.  However, that doesn't 
work and I've tried all kinds of combinations of Show, SplitVertically, 
UpdateSize, and Layout.

I think I have isolated the problem in this code snippet (also attached). 
This code actually works.  But un-comment the 2 lines for splitter2 and you 
will see the problem:
    #!/usr/bin/env python
    import wx

    class myFrame(wx.Frame):
        def __init__(self, parent):
            wx.Frame.__init__(self,
                              parent=parent)
            self.SetClientSize(wx.Size(600, 500))
            self.splitter1=wx.SplitterWindow(self)
            self.splitter1.Hide()
            #self.splitter2=wx.SplitterWindow(self)  # un-comment and you'll
            #self.splitter2.Hide()                   # see the problem
        def showSplitter(self, id):
            if id==1:
                self.splitter1.Show()
            if id==2:
                self.splitter2.Show()

    class myApp(wx.App):
        def OnInit(self):
            wx.InitAllImageHandlers()
            self.mainWin = myFrame(None)
            self.mainWin.Show()
            self.SetTopWindow(self.mainWin)
            self.mainWin.showSplitter(1)

            return True

    if __name__ == '__main__':
        application = myApp(0)
        application.MainLoop()

I have cut it down to the bone, so there are no children in the 
SplitterWindow's and they are not even splitted.  I assure you that the same 
is happening in those cases.  I am not invoking any Layout( ) here, but I've 
tried that too.

Can anyone explain what is happening here?  Am I missing a step somewhere? 
Or could this actually be a bug in SplitterWindow?

Dan 





More information about the Python-list mailing list