The Splitter widget

What does it do?

The Splitter widget takes two subwindows and displays them next to each other, divided by a bar in the middle. This bar can be moved to make one window larger and the other smaller.

Creating an instance

Splitter(parent, size=None, **kwargs)

To create a Splitter, stating the parent usually suffices.

Styles

...

Events

...

Common actions

Creating a Splitter with two subwindows

This isn't difficult, but it requires a few careful steps.

1. Create the splitter. (Splitters are widgets like any others, so they need a parent.)
2. Create the first subwindow, with the splitter as the parent.
3. Ditto for the second subwindow.
4. Add the subwindows to the splitter using splitter.Split(window1, window2). (You can set the direction option here. Possible values are 'horizontal' and 'vertical'; these values indicate the direction of the splitter bar.)
5. Don't forget to add the splitter to a container as usual. (E.g. myframe.AddComponent(splitter).)

The above is demonstrated in the following example.

# splitter-1.py

from wax import *

class MainFrame(Frame):
    def Body(self):
        s = Splitter(self)
        # create first subwindow
        p1 = Panel(s)
        p1.BackgroundColor = 'yellow'
        # create second subwindow
        p2 = Panel(s)
        p2.BackgroundColor = 'red'
        # add to splitter
        s.Split(p1, p2, direction='vertical')
        # add splitter to Frame, and pack
        s.Size = 200, 200 # splitters have a size too!
        self.AddComponent(s, expand='both')
        self.Pack()

app = Application(MainFrame, title='splitter-1')
app.Run()

The results looks like this:

/* todo: nesting splitters? */

Methods

...

Troubleshooting

Q. I have a Frame containing a Splitter. No matter if I set the sizes of the subwindows or not, the resulting window is very small. What gives?

A. Splitters are widgets like any others, and as such, need a sizer. Sometimes it's necessary to set the splitter's size itself, sometimes it's enough to set the size of the splitter's parent (in this case, the frame). The original size of the subwindows is irrelevant, because they will be automatically resized by the splitter.