2

I am quiet new to wxPython, so I hope there is nothing basic I am overlooking: I want to use a SplitterWindow to split up my Frame's content in two resizable subwindows (A and B), but I want one of the windows (B) to have a MaxSize set.

Unfortunately, this poses a problem:

  1. When I resize (enlarge), the whole frame (I am trying to adapt to the the wxPython terminology here; normally, I would say: resize the window), I would hope once the maxSize of the of Window B is reached, Window A would automatically be enlarged to fill the whole content of the frame. Sadly, it does not.

  2. How do make sure that I am not able to move the sash to the left (decrease size of Window B)? In the current situation, Window B just moves to the left (does not change width) and exposes the blue background of the WindowSplitter.

Here's my code:

import wx         

class MainWindow(wx.Frame):

    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(500,300))

        # Create View
        self.loadView()

        #self.SetAutoLayout(1)
        self.GetSizer().Fit(self)
        self.Centre()
        self.Show()

    def loadView(self):        
        splitter = wx.SplitterWindow(self, wx.ID_ANY, style = wx.SP_BORDER, size=(500, 300))
        splitter.SetBackgroundColour('#0000ff')

        panelLeft = wx.Panel(splitter, size=(200,100))
        panelLeft.SetBackgroundColour('#00ff00')

        panelRight = wx.Panel(splitter, size=(200,100))
        panelRight.SetBackgroundColour('#ff0000')
        panelRight.SetMaxSize((200, -1))

        splitter.SplitVertically(panelLeft, panelRight)

        self.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
        self.GetSizer().Add(splitter, 1, wx.EXPAND)


app = wx.App(False)
frame = MainWindow(None, "Test")
app.MainLoop()

A picture speaks a thousand words: enter image description here The blue area is part of the splitter, but not filled up by Window A.

Any help/hint in the right direction is appreciated.

Thanks, Daniel

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
38leinaD
  • 93
  • 1
  • 8
  • Just updated the post with a second related question that I forgot before and actually describes the problem when moving the sash. (1.) is already answered by Donkopotamus. Thanks – 38leinaD Sep 26 '11 at 23:18

1 Answers1

4

I no longer actively work with wx so cannot test a solution. However I believe what you are looking for is

SetSashGravity(0.5)

The default behaviour of a SplitterWindow is that upon a Resize event, only the Right or Bottom window will be resized. And in your case you have imposed a maximum size upon that window.

See the docs for SetSashGravity

donkopotamus
  • 22,114
  • 2
  • 48
  • 60
  • 2
    Hi Donkopotamus; Thanks. Actually, SetSashGravity(1.0) is the parameter i needed so Window A is resized once Window B has reached its MaxSize. – 38leinaD Sep 26 '11 at 23:12