[wxPython-users] problem setting the sashposition of a SplitterWindow

Humberto Abdelnur humberto.abdelnur at loria.fr
Fri Oct 26 09:02:11 PDT 2007


Yes, the problem is that i can not specified the sashposition as at all (ne=
ither absolute nor relative).  =

I ve no control at all in the rightmost sashposition when i ve the outer no=
tebook. The code is below. =

I added a few more frames to pictured better in the screenshot. =

You can see there that in the first 2 frame (the ones without the outer Not=
ebook), i m able to set the sashpositions as i want.
However, in the last 3 frames (the ones with an outer Notebook) the sashpos=
ition of the rigthmost splitter is not modified.

I hope the screenshot make it clear.

ps: in case that the screenshot attached does not work, i also upload it to=
 my page
http://www.loria.fr/~abdelnur/Screenshot.jpg

#### The last version code #####

import wx
class MyFrame(wx.Frame):
	def __init__(self, parent, id, title, createouterNotebook, positions):
		wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(60=
0, 200))
				=

		print wx
		if createouterNotebook:
			outerpanel =3D wx.Panel(self)
			outerpanelsizer =3D wx.BoxSizer()
			outernotebook =3D wx.Notebook(outerpanel)
			=

			innerpanel =3D wx.Panel(outernotebook)
		else:
			innerpanel =3D wx.Panel(self)
			=

		innerpanelsizer =3D wx.BoxSizer()
		=

		mainsplitter =3D wx.SplitterWindow(innerpanel, -1)

		A =3D wx.Panel(mainsplitter, -1)
		A.SetBackgroundColour(wx.WHITE)
		B =3D wx.Panel(mainsplitter, -1)
		=

		############---Panel B----###################
		vboxPanelB =3D wx.BoxSizer()
		notebookPanelB =3D wx.Notebook(B)
		=

		pagePanelB =3D wx.Panel(notebookPanelB)
		=

		sizerpagePanelB =3D wx.BoxSizer()
		splitter2 =3D wx.SplitterWindow(pagePanelB, -1)
		=

		B_1 =3D wx.Panel(splitter2, -1)
		B_1.SetBackgroundColour(wx.LIGHT_GREY)
		B_2 =3D 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, positions[0])
		splitter2.SplitVertically(B_1, B_2, positions[1])
		=

		if createouterNotebook:
			outernotebook.AddPage(innerpanel, "outerPage")
			outerpanelsizer.Add(outernotebook, 2, wx.EXPAND)
			outerpanel.SetSizer(outerpanelsizer)
		=

		self.Centre()		=


if __name__ =3D=3D '__main__':

	app =3D wx.PySimpleApp()
	frame =3D MyFrame(None, -1, 'splitterwindow(with outerNotebook)sash(200,20=
0)', True, (200,200))
	frame.Show(True)
	frame =3D MyFrame(None, -1, 'splitterwindow(with outerNotebook)sash(100,15=
0)', True, (100,150))
	frame.Show(True)
	frame =3D MyFrame(None, -1, 'splitterwindow(with outerNotebook)sash(150,20=
0)', True,  (150,200))
	frame.Show(True)
	frame =3D MyFrame(None, -1, 'splitterwindow(without outerNotebook)sash(100=
,200)', False, (100,200))
	frame.Show(True)
	frame =3D MyFrame(None, -1, 'splitterwindow(without outerNotebook)sash(150=
,100)', False, (150,100))
	frame.Show(True)
	=

	app.MainLoop()




Fri, 26 Oct 2007 08:30:36 -0500
I'm still and not quite sure what you're trying to accomplish. When you
say the sash in the right splitter does not take into consideration the
given position, do you mean it doesn't set the position as you
specified? Or you want it's position to be referenced from the left side
of the entire frame? Perhaps you could attach your latest code and a
screenshot of what it is doing, and what you want it to be doing.


Kyle Rickey

-----Original Message-----
From: Humberto Abdelnur [mailto:humberto.abdelnur at loria.fr] =

Sent: Friday, October 26, 2007 1:55 AM
To: wxPython-users at lists.wxwidgets.org
Subject: RE: [wxPython-users] problem setting the sashposition of a
SplitterWindow

Yes, you well understood, but for me it is not working as it should. =

In both frames the sashpositition of the leftmost splitter is working
fine. =

But in the first frame(the one with the outer notebook), the
sashposition from the right splitter does not take in consideration the
given position.
(this test was with debian and python-wxgtk2.6)

now, where the things get worse, i upgrade the version to
python-wxgtk2.8 and in both frames the sashposition of the rigthmost is
not working well.
But in the first frame none of the positions are considered.

Humberto

ps: I dont ve a window pc to test it on :s



This code seems to work ok for me on MSW. Both frames have the left side
of the mainsplitter at 200 width. Then, the left panel of splitter 2 in
both frame is also 200 width. Or am I misunderstanding what you want?

 =


 =


Kyle Rickey

 =


-----Original Message-----
From: Humberto Abdelnur [mailto:humberto.abdelnur at loria.fr] =

Sent: Thursday, October 25, 2007 4:01 AM
To: wxpython-users at lists.wxwidgets.org
Subject: Re: [wxPython-users] 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 =3D wx.Panel(self)
            outerpanelsizer =3D wx.BoxSizer()
            outernotebook =3D wx.Notebook(outerpanel)
            =

            innerpanel =3D wx.Panel(outernotebook)
        else:
            innerpanel =3D wx.Panel(self) =

            =

        innerpanelsizer =3D wx.BoxSizer()
        =

        mainsplitter =3D wx.SplitterWindow(innerpanel, -1)

        A =3D wx.Panel(mainsplitter, -1)
        A.SetBackgroundColour(wx.WHITE)
        B =3D wx.Panel(mainsplitter, -1)
        =

        ############---Panel B----###################
        vboxPanelB =3D wx.BoxSizer()
        notebookPanelB =3D wx.Notebook(B)
        =

        pagePanelB =3D wx.Panel(notebookPanelB)
        =

        sizerpagePanelB =3D wx.BoxSizer()
        splitter2 =3D wx.SplitterWindow(pagePanelB, -1)
        =

        B 1 =3D wx.Panel(splitter2, -1)
        B 1.SetBackgroundColour(wx.LIGHT GREY)
        B 2 =3D 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   =3D=3D '  main  ':

    app =3D wx.PySimpleApp()
    frame =3D MyFrame(None, -1, 'splitterwindow(with outherNotebook)',
True)
    frame.Show(True)
    frame =3D 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=3D (None,None)):
        wx.Frame.  init  (self, parent, id, title, wx.DefaultPosition, =

wx.Size
(500, 300))
        mainsplitter =3D wx.SplitterWindow(self, -1)
       =

        A =3D wx.Panel(mainsplitter, -1)
        A.SetBackgroundColour(wx.LIGHT GREY)
       =

        B =3D wx.Panel(mainsplitter, -1)
 =

        vbox =3D wx.BoxSizer()
       =

        splitter2 =3D wx.SplitterWindow(B, -1)
       =

        B 1 =3D wx.Panel(splitter2, -1)
        B 1.SetBackgroundColour(wx.LIGHT GREY)
        B 2 =3D 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   =3D=3D '  main  ':
 =

    app =3D wx.PySimpleApp()
    frame =3D MyFrame(None, -1, =

'splitterwindow(FirstSash=3D100,SecondSash=3D100)', splittersash=3D(100,100=
))
 =

    frame.Show(True)
    frame =3D MyFrame(None, -1, =

'splitterwindow(FirstSash=3D100,SecondSash=3D200)', splittersash=3D(100,200=
))
    frame.Show(True)
    frame =3D MyFrame(None, -1, =

'splitterwindow(FirstSash=3D200,SecondSash=3D200)', splittersash=3D(200,200=
))
 =

    frame.Show(True)
    app.MainLoop()
 =

 =

-----Original Message-----
From: Humberto Abdelnur [mailto:humberto.abdelnur at loria.fr] =

Sent: Wednesday, October 24, 2007 4:28 AM
 =

To: wxpython-users at 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=3D (None,None)):
        wx.Frame.  init  (self, parent, id, title, =

wx.DefaultPosition, =

wx.Size(400, 300))
       =

        mainsplitter =3D wx.SplitterWindow(self, -1)
       =

        A =3D wx.Panel(mainsplitter, -1)
        A.SetBackgroundColour(wx.LIGHT GREY)
       =

 =

        B =3D wx.Panel(mainsplitter, -1)
        vbox =3D wx.BoxSizer()
       =

        splitter2 =3D wx.SplitterWindow(B, -1)
       =

        B 1 =3D wx.Panel(splitter2, -1)
        B 1.SetBackgroundColour(wx.LIGHT
 GREY)
        B 2 =3D 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   =3D=3D '  main  ':
 =

    app =3D wx.PySimpleApp()
    frame =3D MyFrame(None, -1, =

 =

'splitterwindow(FirstSash=3D100,SecondSash=3D100)', splittersash=3D(100,100=
))
    frame.Show(True)
    frame =3D MyFrame(None, -1, =

'splitterwindow(FirstSash=3D100,SecondSash=3D200)', splittersash=3D(100,200=
))
 =

    frame.Show(True)
    frame =3D MyFrame(None, -1, =

'splitterwindow(FirstSash=3D200,SecondSash=3D200)', splittersash=3D(200,200=
))
    frame.Show(True)
    app.MainLoop()
 =

---------------------------------------------------------------------
 =

To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
For additional commands, e-mail:
<mailto:wxPython-users-help at lists.wxwidgets.org> =

wxPython-users-help at lists.wxwidgets.org
--------------------------------------------------------------------- To
unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org For
additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot.jpg
Type: image/jpeg
Size: 59050 bytes
Desc: not available
Url : http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/20071=
026/1f0db038/Screenshot.jpg


More information about the wxpython-users mailing list