A couple of things:
First, I made your window wider to 500 so you can see the all the panels
in the case of setting both sashes to 200. Second, you need to split
splitter2 vertically after you have split mainsplitter. I don't know why
that it, but it worked on my system. Lastly, you were using
splittersash[0] for splitter2 and splittersash[1] for mainsplitter, you
want them the other way around.
I hope this gets you on the right track. Modified code below.
Kyle Rickey
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title, splittersash= (None,None)):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.Size(500, 300))
mainsplitter = wx.SplitterWindow(self, -1)
A = wx.Panel(mainsplitter, -1)
A.SetBackgroundColour(wx.LIGHT_GREY)
B = wx.Panel(mainsplitter, -1)
vbox = wx.BoxSizer()
splitter2 = wx.SplitterWindow(B, -1)
B_1 = wx.Panel(splitter2, -1)
B_1.SetBackgroundColour(wx.LIGHT_GREY)
B_2 = wx.Panel(splitter2, -1)
B_2.SetBackgroundColour(wx.WHITE)
vbox.Add(splitter2, 2, wx.EXPAND)
B.SetSizer(vbox)
mainsplitter.SplitVertically(A, B, splittersash[0])
splitter2.SplitVertically(B_1, B_2, splittersash[1])
self.Centre()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MyFrame(None, -1,
'splitterwindow(FirstSash=100,SecondSash=100)', splittersash=(100,100))
frame.Show(True)
frame = MyFrame(None, -1,
'splitterwindow(FirstSash=100,SecondSash=200)', splittersash=(100,200))
frame.Show(True)
frame = MyFrame(None, -1,
'splitterwindow(FirstSash=200,SecondSash=200)', splittersash=(200,200))
frame.Show(True)
app.MainLoop()
ยทยทยท
-----Original Message-----
From: Humberto Abdelnur [mailto:humberto.abdelnur@loria.fr]
Sent: Wednesday, October 24, 2007 4:28 AM
To: wxpython-users@lists.wxwidgets.org
Subject: [wxPython-users] problem setting the sashposition of a
SplitterWindow
Hi everyone,
I'm having problems setting the sashposition of a SplitterWindow.
In fact, the problem arises every time that one SplitterWindow is a
children of component, in my code a page of a notebook, and that
notebook is one of the windows in a outsider SplitterWindow.
To illustrate the problem, an example code is at end of the mail.
It makes 3 frames, each one of them with a format like
----------------------------
----------------------------
A | B_1 | B_2 |
----------------------------
Where a main splitter is between panels A and B. And B itself has
another splitter with contains the Panels B_1 and B2.
So, the sashposition of the splitter (A,B) works perfectly. however, i
m not able to set the position for the splitter (B_1,B_2)
Thanks in advance,
Humberto
########################################################
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id, title, splittersash= (None,None)):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,
wx.Size(400, 300))
mainsplitter = wx.SplitterWindow(self, -1)
A = wx.Panel(mainsplitter, -1)
A.SetBackgroundColour(wx.LIGHT_GREY)
B = wx.Panel(mainsplitter, -1)
vbox = wx.BoxSizer()
splitter2 = wx.SplitterWindow(B, -1)
B_1 = wx.Panel(splitter2, -1)
B_1.SetBackgroundColour(wx.LIGHT_GREY)
B_2 = wx.Panel(splitter2, -1)
B_2.SetBackgroundColour(wx.WHITE)
splitter2.SplitVertically(B_1, B_2, splittersash[0])
vbox.Add(splitter2, 1, wx.EXPAND)
B.SetSizer(vbox)
mainsplitter.SplitVertically(A, B, splittersash[1])
self.Centre()
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = MyFrame(None, -1,
'splitterwindow(FirstSash=100,SecondSash=100)', splittersash=(100,100))
frame.Show(True)
frame = MyFrame(None, -1,
'splitterwindow(FirstSash=100,SecondSash=200)', splittersash=(100,200))
frame.Show(True)
frame = MyFrame(None, -1,
'splitterwindow(FirstSash=200,SecondSash=200)', splittersash=(200,200))
frame.Show(True)
app.MainLoop()
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org