[wxPython] Problem with SetSashPosition on a wxSplitterWindow

I’m trying to adjust the position of a splitter window
with a call to SetSashPosition. This worked correctly
when I was using wxPython version 2.3.1 but now that
I have upgraded to 2.3.3.1 it no longer works. I’ve found that the same problem
exists with the wxPython demo for the splitter
window. In line 39 of the splitter window demo there is a call to splitter.SetSashPosition(100) which seems to have no effect - the splitter window
always starts off exactly in the middle of the parent window.

Is there another way to do this?

Thanks,

        Colin.

I've noticed this too, and is one of the reasons I held off from upgrading
to 2.3.2.1. Just hadn't gotten around to mailing the list. Any solution?

                         -- Mike

···

On Thu, Oct 24 @ 17:09, Colin Bradbury wrote:

I'm trying to adjust the position of a splitter window with a call to
SetSashPosition. This worked correctly when I was using wxPython version
2.3.1 but now that I have upgraded to 2.3.3.1 it no longer works. I've found
that the same problem exists with the wxPython demo for the splitter window.
In line 39 of the splitter window demo there is a call to
splitter.SetSashPosition(100) which seems to have no effect - the splitter
window always starts off exactly in the middle of the parent window.

Is there another way to do this?

Thanks,
            Colin.

--
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html

  I've noticed this too, and is one of the reasons I held off from upgrading
to 2.3.2.1. Just hadn't gotten around to mailing the list. Any solution?

Yes... well, maybe :slight_smile:
I've spent nearly a whole afternoon trying to understand the new behaviour of wxSplitterWindow, which I considered buggy (and now just counter-intuitive). Here's what I came up with:

- SetSashPosition has an effect only if the splitter window is visible, otherwise it does nothing

- The best way to set the sash pos is to use the 3rd parameter of SplitHorizontally (and also SplitVertically). As regards the demo, the code should be changed from:

    splitter.SplitVertically(p1, p2)
    splitter.SetSashPosition(100)

to simply:

    splitter.SplitVertically(p1, p2, 100)
   
Hope that this helps.

Cheers,
Alberto

Great. Can't wait to try it out. Does the third solution need to be
visible? I'm sure Robin will pick this up as a bug report.

                              -- Mike

···

On Thu, Oct 24 @ 21:04, Alberto Griggio wrote:

Yes... well, maybe :slight_smile:
I've spent nearly a whole afternoon trying to understand the new behaviour of wxSplitterWindow, which I considered buggy (and now just counter-intuitive). Here's what I came up with:

- SetSashPosition has an effect only if the splitter window is visible, otherwise it does nothing

- The best way to set the sash pos is to use the 3rd parameter of SplitHorizontally (and also SplitVertically). As regards the demo, the code should be changed from:

    splitter.SplitVertically(p1, p2)
    splitter.SetSashPosition(100)

to simply:

    splitter.SplitVertically(p1, p2, 100)

--
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html

  Great. Can't wait to try it out. Does the third solution need to be
visible? I'm sure Robin will pick this up as a bug report.

Well, I remembered wrong :frowning: Reading the sources again, I saw that the problem is not the window's visibility, but its size: with 2.3.3 you cannot set a sash position greater than the width (or height) of the window, so SetSashPosition should be called after having set the size (either manually or by placing the window inside a sizer, for example). As this change is AFAIK intentional, I don't think it can be called a bug (maybe a documentation issue, anyway).

Cheers,
Alberto