]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/SashWindow.py
4 #---------------------------------------------------------------------------
6 class TestSashWindow(wx
.Panel
):
10 ID_WINDOW_BOTTOM
= 5103
13 def __init__(self
, parent
, log
):
14 wx
.Panel
.__init
__(self
, parent
, -1)
18 # will occupy the space not used by the Layout Algorithm
19 self
.remainingSpace
= wx
.Panel(self
, -1, style
=wx
.SUNKEN_BORDER
)
22 wx
.EVT_SASH_DRAGGED_RANGE
, self
.OnSashDrag
,
23 id=self
.ID_WINDOW_TOP
, id2
=self
.ID_WINDOW_BOTTOM
,
26 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
29 # Create some layout windows
30 # A window like a toolbar
31 win
= wx
.SashLayoutWindow(
32 self
, self
.ID_WINDOW_TOP
, wx
.DefaultPosition
, (200, 30),
36 win
.SetDefaultSize((1000, 30))
37 win
.SetOrientation(wx
.LAYOUT_HORIZONTAL
)
38 win
.SetAlignment(wx
.LAYOUT_TOP
)
39 win
.SetBackgroundColour(wx
.Colour(255, 0, 0))
40 win
.SetSashVisible(wx
.SASH_BOTTOM
, True)
45 # A window like a statusbar
46 win
= wx
.SashLayoutWindow(
47 self
, self
.ID_WINDOW_BOTTOM
, wx
.DefaultPosition
, (200, 30),
51 win
.SetDefaultSize((1000, 30))
52 win
.SetOrientation(wx
.LAYOUT_HORIZONTAL
)
53 win
.SetAlignment(wx
.LAYOUT_BOTTOM
)
54 win
.SetBackgroundColour(wx
.Colour(0, 0, 255))
55 win
.SetSashVisible(wx
.SASH_TOP
, True)
57 self
.bottomWindow
= win
59 # A window to the left of the client window
60 win
= wx
.SashLayoutWindow(
61 self
, self
.ID_WINDOW_LEFT1
, wx
.DefaultPosition
, (200, 30),
65 win
.SetDefaultSize((120, 1000))
66 win
.SetOrientation(wx
.LAYOUT_VERTICAL
)
67 win
.SetAlignment(wx
.LAYOUT_LEFT
)
68 win
.SetBackgroundColour(wx
.Colour(0, 255, 0))
69 win
.SetSashVisible(wx
.SASH_RIGHT
, True)
70 win
.SetExtraBorderSize(10)
71 textWindow
= wx
.TextCtrl(
72 win
, -1, "", wx
.DefaultPosition
, wx
.DefaultSize
,
73 wx
.TE_MULTILINE|wx
.SUNKEN_BORDER
76 textWindow
.SetValue("A sub window")
78 self
.leftWindow1
= win
81 # Another window to the left of the client window
82 win
= wx
.SashLayoutWindow(
83 self
, self
.ID_WINDOW_LEFT2
, wx
.DefaultPosition
, (200, 30),
87 win
.SetDefaultSize((120, 1000))
88 win
.SetOrientation(wx
.LAYOUT_VERTICAL
)
89 win
.SetAlignment(wx
.LAYOUT_LEFT
)
90 win
.SetBackgroundColour(wx
.Colour(0, 255, 255))
91 win
.SetSashVisible(wx
.SASH_RIGHT
, True)
93 self
.leftWindow2
= win
96 def OnSashDrag(self
, event
):
97 if event
.GetDragStatus() == wx
.SASH_STATUS_OUT_OF_RANGE
:
102 if eID
== self
.ID_WINDOW_TOP
:
103 self
.topWindow
.SetDefaultSize((1000, event
.GetDragRect().height
))
105 elif eID
== self
.ID_WINDOW_LEFT1
:
106 self
.leftWindow1
.SetDefaultSize((event
.GetDragRect().width
, 1000))
109 elif eID
== self
.ID_WINDOW_LEFT2
:
110 self
.leftWindow2
.SetDefaultSize((event
.GetDragRect().width
, 1000))
112 elif eID
== self
.ID_WINDOW_BOTTOM
:
113 self
.bottomWindow
.SetDefaultSize((1000, event
.GetDragRect().height
))
115 wx
.LayoutAlgorithm().LayoutWindow(self
, self
.remainingSpace
)
116 self
.remainingSpace
.Refresh()
118 def OnSize(self
, event
):
119 wx
.LayoutAlgorithm().LayoutWindow(self
, self
.remainingSpace
)
121 #---------------------------------------------------------------------------
123 def runTest(frame
, nb
, log
):
124 win
= TestSashWindow(nb
, log
)
127 #---------------------------------------------------------------------------
131 wx.SashLayoutWindow responds to OnCalculateLayout events generated by
132 wxLayoutAlgorithm. It allows the application to use simple accessors to
133 specify how the window should be laid out, rather than having to respond
134 to events. The fact that the class derives from wx.SashWindow allows sashes
135 to be used if required, to allow the windows to be user-resizable.
137 The documentation for wx.LayoutAlgorithm explains the purpose of this class
143 if __name__
== '__main__':
146 run
.main(['', os
.path
.basename(sys
.argv
[0])])