3 from wx
.lib
.splitter 
import MultiSplitterWindow
 
   5 #---------------------------------------------------------------------- 
   7 class SamplePane(wx
.Panel
): 
   9     Just a simple test window to put into the splitter. 
  11     def __init__(self
, parent
, colour
, label
): 
  12         wx
.Panel
.__init
__(self
, parent
, style
=wx
.BORDER_SUNKEN
) 
  13         self
.SetBackgroundColour(colour
) 
  14         wx
.StaticText(self
, -1, label
, (5,5)) 
  16     def SetOtherLabel(self
, label
): 
  17         wx
.StaticText(self
, -1, label
, (5, 30)) 
  21 class ControlPane(wx
.Panel
): 
  22     def __init__(self
, parent
): 
  23         wx
.Panel
.__init
__(self
, parent
) 
  25         hvBox 
= wx
.RadioBox(self
, -1, "Orientation", 
  26                             choices
=["Horizontal", "Vertical"], 
  27                             style
=wx
.RA_SPECIFY_COLS
, 
  30         self
.Bind(wx
.EVT_RADIOBOX
, self
.OnSetHV
, hvBox
) 
  32         luCheck 
= wx
.CheckBox(self
, -1, "Live Update") 
  33         luCheck
.SetValue(True) 
  34         self
.Bind(wx
.EVT_CHECKBOX
, self
.OnSetLiveUpdate
, luCheck
) 
  36         btn 
= wx
.Button(self
, -1, "Swap 2 && 4") 
  37         self
.Bind(wx
.EVT_BUTTON
, self
.OnSwapButton
, btn
) 
  39         sizer 
= wx
.BoxSizer(wx
.VERTICAL
) 
  41         sizer
.Add(luCheck
, 0, wx
.TOP
, 5) 
  42         sizer
.Add(btn
, 0, wx
.TOP
, 5) 
  43         border 
= wx
.BoxSizer() 
  44         border
.Add(sizer
, 1, wx
.EXPAND|wx
.ALL
, 5) 
  48     def OnSetHV(self
, evt
): 
  49         rb 
= evt
.GetEventObject() 
  50         self
.GetParent().SetOrientation(rb
.GetSelection()) 
  53     def OnSetLiveUpdate(self
, evt
): 
  54         check 
= evt
.GetEventObject() 
  55         self
.GetParent().SetLiveUpdate(check
.GetValue()) 
  58     def OnSwapButton(self
, evt
): 
  59         self
.GetParent().Swap2and4() 
  63 class TestPanel(wx
.Panel
): 
  64     def __init__(self
, parent
, log
): 
  66         wx
.Panel
.__init
__(self
, parent
, -1) 
  68         cp 
= ControlPane(self
) 
  70         splitter 
= MultiSplitterWindow(self
, style
=wx
.SP_LIVE_UPDATE
) 
  71         self
.splitter 
= splitter
 
  72         sizer 
= wx
.BoxSizer(wx
.HORIZONTAL
) 
  74         sizer
.Add(splitter
, 1, wx
.EXPAND
) 
  78         p1 
= SamplePane(splitter
, "pink", "Panel One") 
  80             "There are two sash\n" 
  86         splitter
.AppendWindow(p1
, 140) 
  88         p2 
= SamplePane(splitter
, "sky blue", "Panel Two") 
  89         p2
.SetOtherLabel("This window\nhas a\nminsize.") 
  90         p2
.SetMinSize(p2
.GetBestSize()) 
  91         splitter
.AppendWindow(p2
, 150) 
  93         p3 
= SamplePane(splitter
, "yellow", "Panel Three") 
  94         splitter
.AppendWindow(p3
, 125) 
  96         p4 
= SamplePane(splitter
, "Lime Green", "Panel Four") 
  97         splitter
.AppendWindow(p4
) 
  99         self
.Bind(wx
.EVT_SPLITTER_SASH_POS_CHANGED
, self
.OnChanged
) 
 100         self
.Bind(wx
.EVT_SPLITTER_SASH_POS_CHANGING
, self
.OnChanging
) 
 103     def OnChanging(self
, evt
): 
 104         self
.log
.write( "Changing sash:%d  %s\n" % 
 105                         (evt
.GetSashIdx(), evt
.GetSashPosition())) 
 106         # This is one way to control the sash limits 
 107         #if evt.GetSashPosition() < 50: 
 110         # Or you can reset the sash position to whatever you want 
 111         #if evt.GetSashPosition() < 5: 
 112         #    evt.SetSashPosition(25) 
 115     def OnChanged(self
, evt
): 
 116         self
.log
.write( "Changed sash:%d  %s\n" % 
 117                         (evt
.GetSashIdx(), evt
.GetSashPosition())) 
 120     def SetOrientation(self
, value
): 
 122             self
.splitter
.SetOrientation(wx
.VERTICAL
) 
 124             self
.splitter
.SetOrientation(wx
.HORIZONTAL
) 
 125         self
.splitter
.SizeWindows() 
 128     def SetLiveUpdate(self
, enable
): 
 130             self
.splitter
.SetWindowStyle(wx
.SP_LIVE_UPDATE
) 
 132             self
.splitter
.SetWindowStyle(0) 
 136         win2 
= self
.splitter
.GetWindow(1) 
 137         win4 
= self
.splitter
.GetWindow(3) 
 138         self
.splitter
.ExchangeWindows(win2
, win4
) 
 140 #---------------------------------------------------------------------- 
 142 def runTest(frame
, nb
, log
): 
 143     win 
= TestPanel(nb
, log
) 
 146 #---------------------------------------------------------------------- 
 150 overview 
= """<html><body> 
 151 <h2><center>MultiSplitterWindow</center></h2> 
 153 This class is very similar to wx.SplitterWindow except that it 
 154 allows for more than two windows and more than one sash.  Many of 
 155 the same styles, constants, and methods behave the same as in 
 163 if __name__ 
== '__main__': 
 166     run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])