problem setting the sashposition of a SplitterWindow

Hi, thanks a lot for the reply, in fact that worked out. But i tried to
applied to my real code and it didnt fix it :s

I guess there is something buggy around it. The problem also arise when
there are inner notebooks.

I added a few things to the previous example to show it off. I also
tried to play with the order in which i add pages and split the
splitters, but i didnt find any results.

For the example, it creates two frames, one with an inner notebook and
the other not.

thanks again,

Humberto

import wx

class MyFrame(wx.Frame):

def __init__(self, parent, id, title, createouterNotebook):

    wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition,

wx.Size(600, 300))

    if createouterNotebook:

        outerpanel = wx.Panel(self)

        outerpanelsizer = wx.BoxSizer()

        outernotebook = wx.Notebook(outerpanel)

        

        innerpanel = wx.Panel(outernotebook)

    else:

        innerpanel = wx.Panel(self)

        

    innerpanelsizer = wx.BoxSizer()

    

    mainsplitter = wx.SplitterWindow(innerpanel, -1)

    A = wx.Panel(mainsplitter, -1)

    A.SetBackgroundColour(wx.WHITE)

    B = wx.Panel(mainsplitter, -1)

    

    ############---Panel B----###################

    vboxPanelB = wx.BoxSizer()

    notebookPanelB = wx.Notebook(B)

    

    pagePanelB = wx.Panel(notebookPanelB)

    

    sizerpagePanelB = wx.BoxSizer()

    splitter2 = wx.SplitterWindow(pagePanelB, -1)

    

    B_1 = wx.Panel(splitter2, -1)

    B_1.SetBackgroundColour(wx.LIGHT_GREY)

    B_2 = wx.Panel(splitter2, -1)

    B_2.SetBackgroundColour(wx.WHITE)

    sizerpagePanelB.Add(splitter2,  2, wx.EXPAND)

    pagePanelB.SetSizer(sizerpagePanelB)

    

    notebookPanelB.AddPage(pagePanelB, "innerPage")

    vboxPanelB.Add(notebookPanelB, 2, wx.EXPAND)

    B.SetSizer(vboxPanelB)

    ############---Panel B----###################

    

    innerpanelsizer.Add(mainsplitter,  2, wx.EXPAND)

    innerpanel.SetSizer(innerpanelsizer)

    

    mainsplitter.SplitVertically(A, B, 200)

    splitter2.SplitVertically(B_1, B_2, 200)

    

    if createouterNotebook:

        outernotebook.AddPage(innerpanel, "outerPage")

        outerpanelsizer.Add(outernotebook, 2, wx.EXPAND)

        outerpanel.SetSizer(outerpanelsizer)

    

    self.Centre()        

if name == ‘main’:

app = wx.PySimpleApp()

frame = MyFrame(None, -1, 'splitterwindow(with outherNotebook)',

True)

frame.Show(True)

frame = MyFrame(None, -1, 'splitterwindow(witout outherNotebook)',

False)

frame.Show(True)



app.MainLoop()
···

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