]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/SplitterWindow.py
A patch from Frame Niessink which adds an additional style that
[wxWidgets.git] / wxPython / demo / SplitterWindow.py
1
2 import wx
3
4 #---------------------------------------------------------------------------
5
6 class MySplitter(wx.SplitterWindow):
7 def __init__(self, parent, ID, log):
8 wx.SplitterWindow.__init__(self, parent, ID,
9 style = wx.SP_LIVE_UPDATE
10 )
11 self.log = log
12
13 self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
14 self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
15
16 def OnSashChanged(self, evt):
17 self.log.WriteText("sash changed to %s\n" % str(evt.GetSashPosition()))
18
19 def OnSashChanging(self, evt):
20 self.log.WriteText("sash changing to %s\n" % str(evt.GetSashPosition()))
21 # uncomment this to not allow the change
22 #evt.SetSashPosition(-1)
23
24
25 #---------------------------------------------------------------------------
26
27 def runTest(frame, nb, log):
28 splitter = MySplitter(nb, -1, log)
29
30 #sty = wx.BORDER_NONE
31 #sty = wx.BORDER_SIMPLE
32 sty = wx.BORDER_SUNKEN
33
34 p1 = wx.Window(splitter, style=sty)
35 p1.SetBackgroundColour("pink")
36 wx.StaticText(p1, -1, "Panel One", (5,5))
37
38 p2 = wx.Window(splitter, style=sty)
39 p2.SetBackgroundColour("sky blue")
40 wx.StaticText(p2, -1, "Panel Two", (5,5))
41
42 splitter.SetMinimumPaneSize(20)
43 splitter.SplitVertically(p1, p2, -100)
44
45 return splitter
46
47
48 #---------------------------------------------------------------------------
49
50
51 overview = """\
52 This class manages up to two subwindows. The current view can be split
53 into two programmatically (perhaps from a menu command), and unsplit
54 either programmatically or via the wx.SplitterWindow user interface.
55 """
56
57 if __name__ == '__main__':
58 import sys,os
59 import run
60 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
61