Resizing a SpliterWindow

I haven’t been able to figure out how to control which part of a
SplitterWindow is changed on a window resize. My application is split
into a top panel and bottom panel. The top panel is the main
application, and the bottom panel displays status messages. When user
resizes a
window, I want the extra space to go into the top panel.

Everything
I have tried so far has the bottom panel resizing. I have tried several
things with sizers to no avail. Obviously the user could change the
splitter, but I know resizing can be made to work because I see
applications do it (e.g., PyCrust) I just haven’t found the secret.

Here is the simple example. When the user resizes, the bottom panel changes size, I want the top panel to change.

import wx

class MyFrame(wx.Frame):
def init(self, *args, **kwargs):

    wx.Frame.__init__(self, *args, **kwargs)

    splitter = wx.SplitterWindow(self)

   
    top = wx.Window(splitter, style=wx.BORDER_SUNKEN)
    wx.StaticText(top, -1, "Top Panel", (5,5))
    bottom = wx.Window(splitter, style=wx.BORDER_SUNKEN)

    wx.StaticText(bottom, -1, "Bottom Panel", (5,5))

    splitter.SplitHorizontally(top, bottom, -100)

    splitter.SetMinimumPaneSize(20)

    splitter.SplitHorizontally(toppane, bottompane, -100)

app = wx.PySimpleApp()

frame = MyFrame(None)
frame.Show()

app.MainLoop()

···


Mike Conley

Add this line:
splitter.SetSashGravity(1.0)

See here:
http://docs.wxwidgets.org/stable/wx_wxsplitterwindow.html#wxsplitterwindowsetsashgravity

Che

···

On Fri, Nov 21, 2008 at 2:31 PM, Mike Conley <mylist@mconley.net> wrote:

I haven't been able to figure out how to control which part of a
SplitterWindow is changed on a window resize. My application is split into a
top panel and bottom panel. The top panel is the main application, and the
bottom panel displays status messages. When user resizes a
window, I want the extra space to go into the top panel.

Everything I have tried so far has the bottom panel resizing. I have tried
several things with sizers to no avail. Obviously the user could change the
splitter, but I know resizing can be made to work because I see applications
do it (e.g., PyCrust) I just haven't found the secret.

Here is the simple example. When the user resizes, the bottom panel changes
size, I want the top panel to change.

import wx
class MyFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        splitter = wx.SplitterWindow(self)

        top = wx.Window(splitter, style=wx.BORDER_SUNKEN)
        wx.StaticText(top, -1, "Top Panel", (5,5))
        bottom = wx.Window(splitter, style=wx.BORDER_SUNKEN)
        wx.StaticText(bottom, -1, "Bottom Panel", (5,5))

        splitter.SplitHorizontally(top, bottom, -100)

        splitter.SetMinimumPaneSize(20)
        splitter.SplitHorizontally(toppane, bottompane, -100)

app = wx.PySimpleApp()
frame = MyFrame(None)
frame.Show()
app.MainLoop()

--
Mike Conley