]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/SplitterWindow.py
Moved @interface wxNSApplicationDelegate to new header
[wxWidgets.git] / wxPython / demo / SplitterWindow.py
CommitLineData
cf694132 1
8fa876ca 2import wx
cf694132 3
6999b0d8
RD
4#---------------------------------------------------------------------------
5
8fa876ca 6class MySplitter(wx.SplitterWindow):
6999b0d8 7 def __init__(self, parent, ID, log):
8fa876ca 8 wx.SplitterWindow.__init__(self, parent, ID)
6999b0d8 9 self.log = log
8fa876ca
RD
10
11 self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnSashChanged)
12 self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGING, self.OnSashChanging)
6999b0d8
RD
13
14 def OnSashChanged(self, evt):
c368d904
RD
15 self.log.WriteText("sash changed to %s\n" % str(evt.GetSashPosition()))
16 # uncomment this to not allow the change
17 #evt.SetSashPosition(-1)
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)
6999b0d8 23
cf694132
RD
24#---------------------------------------------------------------------------
25
26def runTest(frame, nb, log):
6999b0d8 27 splitter = MySplitter(nb, -1, log)
cf694132 28
8fa876ca
RD
29 p1 = wx.Window(splitter, -1)
30 p1.SetBackgroundColour(wx.RED)
31 wx.StaticText(p1, -1, "Panel One", (5,5)).SetBackgroundColour(wx.RED)
cf694132 32
8fa876ca
RD
33 p2 = wx.Window(splitter, -1)
34 p2.SetBackgroundColour(wx.BLUE)
35 wx.StaticText(p2, -1, "Panel Two", (5,5)).SetBackgroundColour(wx.BLUE)
cf694132 36
2f90df85 37 splitter.SetMinimumPaneSize(20)
1e4a197e
RD
38 splitter.SplitVertically(p1, p2, 100)
39
cf694132
RD
40 return splitter
41
42
43#---------------------------------------------------------------------------
44
45
cf694132 46overview = """\
1fded56b
RD
47This class manages up to two subwindows. The current view can be split
48into two programmatically (perhaps from a menu command), and unsplit
95bfd958 49either programmatically or via the wx.SplitterWindow user interface.
1fded56b 50"""
cf694132 51
1fded56b
RD
52if __name__ == '__main__':
53 import sys,os
54 import run
55 run.main(['', os.path.basename(sys.argv[0])])
cf694132 56