Splitter windows: how to keep the sash visible when unsplit?

Chris Mellon wrote

Hi!

Is there a way to keep the sash visible when the splitter window is unsplit?

Thanks,
Klaus

I'm guessing that you mean to have the sash drawn all the way against

Yes, that's right.

the side? In that case you want to override the Unsplit() behavior to
just make one of the windows 0 width (or height).

That doesn't seem to work. SetSashPosition(0) does nothing.
I could live with a size of 1, but there's an additional
problem: The user can still drag the sash to the border of the
frame, and then the sash disappears.

This is the splitter class I wrote to try it, and I am calling
toggleVisible() from the EVT_SPLITTER_DCLICK handler of the frame:

class Splitter(wx.SplitterWindow):
     def __init__(self, *args, **kw):
         wx.SplitterWindow.__init__(self, *args, **kw)
         self.oldPosition = None

     def toggleVisible(self):
         if self.oldPosition:
             self.SetSashPosition(self.oldPosition, True)
             #self.SplitVertically(self.GetWindow1(), self.GetWindow2(), self.oldPosition)
             self.oldPosition = None
         else:
             self.oldPosition = self.GetSashPosition()
             self.Unsplit(self.GetWindow1())

     def Unsplit(self, toRemove):
         self.SetSashPosition(1, True)

···

On 9/17/07, Klaus Nowikow <klaus.nowikow@tuwien.ac.at> wrote:

Sadly, wxSplitterWindow doesn't support a 0 sash position - it
interprets that as "unsplit". There's no way to fix this from Python
code, if you really want it to be drawn correctly you'll need to write
your own custom SplitterWindow (not as hard as it might sound).

If you can live with the 1px size, just use SetMinimumPaneSize(1),
which will disable the autu-unsplit behavior and use
SetSashPosition(1) in your double-click handler.

···

On 9/17/07, Klaus Nowikow <klaus.nowikow@tuwien.ac.at> wrote:

Chris Mellon wrote
> On 9/17/07, Klaus Nowikow <klaus.nowikow@tuwien.ac.at> wrote:
>> Hi!
>>
>> Is there a way to keep the sash visible when the splitter window is unsplit?
>>
>> Thanks,
>> Klaus
>>
>>
>
> I'm guessing that you mean to have the sash drawn all the way against

Yes, that's right.

> the side? In that case you want to override the Unsplit() behavior to
> just make one of the windows 0 width (or height).

That doesn't seem to work. SetSashPosition(0) does nothing.
I could live with a size of 1, but there's an additional
problem: The user can still drag the sash to the border of the
frame, and then the sash disappears.

Chris Mellon schrieb:

···

On 9/18/07, Klaus Nowikow <klaus.nowikow@tuwien.ac.at> wrote:

[...]
Chris Mellon wrote:

Sadly, wxSplitterWindow doesn't support a 0 sash position - it
interprets that as "unsplit". There's no way to fix this from Python
code, if you really want it to be drawn correctly you'll need to write
your own custom SplitterWindow (not as hard as it might sound).

If you can live with the 1px size, just use SetMinimumPaneSize(1),
which will disable the autu-unsplit behavior and use
SetSashPosition(1) in your double-click handler.

Thank you. I'll try writing my own splitter window, as the
SetMinimumPaneSize(1) route doesn't prevent the user from dragging
the sash all the way to one side and unsplitting the window that way.

Actually it does, and it also disables the double-click unsplit behavior.

Sorry, my fault. I accidentally called SetMinimumPaneSize(0) a couple of lines
after SetMinimumPaneSize(1). Removed this line and now it works perfectly.
Thank you!

--
Klaus