2 from wxPython
.wx
import *
4 #---------------------------------------------------------------------------
6 class TestSashWindow(wxPanel
):
10 ID_WINDOW_BOTTOM
= 5103
13 def __init__(self
, parent
, log
):
14 wxPanel
.__init
__(self
, parent
, -1)
18 # will occupy the space not used by the Layout Algorithm
19 self
.remainingSpace
= wxPanel(self
, -1, style
=wxSUNKEN_BORDER
)
21 EVT_SASH_DRAGGED_RANGE(self
, self
.ID_WINDOW_TOP
,
22 self
.ID_WINDOW_BOTTOM
, self
.OnSashDrag
)
23 EVT_SIZE(self
, self
.OnSize
)
26 # Create some layout windows
27 # A window like a toolbar
28 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_TOP
, wxDefaultPosition
,
29 wxSize(200, 30), wxNO_BORDER|wxSW_3D
)
30 win
.SetDefaultSize(wxSize(1000, 30))
31 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
32 win
.SetAlignment(wxLAYOUT_TOP
)
33 win
.SetBackgroundColour(wxColour(255, 0, 0))
34 win
.SetSashVisible(wxSASH_BOTTOM
, true
)
39 # A window like a statusbar
40 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_BOTTOM
,
41 wxDefaultPosition
, wxSize(200, 30),
43 win
.SetDefaultSize(wxSize(1000, 30))
44 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
45 win
.SetAlignment(wxLAYOUT_BOTTOM
)
46 win
.SetBackgroundColour(wxColour(0, 0, 255))
47 win
.SetSashVisible(wxSASH_TOP
, true
)
49 self
.bottomWindow
= win
52 # A window to the left of the client window
53 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT1
,
54 wxDefaultPosition
, wxSize(200, 30),
56 win
.SetDefaultSize(wxSize(120, 1000))
57 win
.SetOrientation(wxLAYOUT_VERTICAL
)
58 win
.SetAlignment(wxLAYOUT_LEFT
)
59 win
.SetBackgroundColour(wxColour(0, 255, 0))
60 win
.SetSashVisible(wxSASH_RIGHT
, TRUE
)
61 win
.SetExtraBorderSize(10)
62 textWindow
= wxTextCtrl(win
, -1, "", wxDefaultPosition
, wxDefaultSize
,
63 wxTE_MULTILINE|wxSUNKEN_BORDER
)
64 textWindow
.SetValue("A sub window")
66 self
.leftWindow1
= win
69 # Another window to the left of the client window
70 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT2
,
71 wxDefaultPosition
, wxSize(200, 30),
73 win
.SetDefaultSize(wxSize(120, 1000))
74 win
.SetOrientation(wxLAYOUT_VERTICAL
)
75 win
.SetAlignment(wxLAYOUT_LEFT
)
76 win
.SetBackgroundColour(wxColour(0, 255, 255))
77 win
.SetSashVisible(wxSASH_RIGHT
, TRUE
)
79 self
.leftWindow2
= win
82 def OnSashDrag(self
, event
):
83 if event
.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE
:
87 if eID
== self
.ID_WINDOW_TOP
:
88 self
.topWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
90 elif eID
== self
.ID_WINDOW_LEFT1
:
91 self
.leftWindow1
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
94 elif eID
== self
.ID_WINDOW_LEFT2
:
95 self
.leftWindow2
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
97 elif eID
== self
.ID_WINDOW_BOTTOM
:
98 self
.bottomWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
100 wxLayoutAlgorithm().LayoutWindow(self
, self
.remainingSpace
)
101 self
.remainingSpace
.Refresh()
103 def OnSize(self
, event
):
104 wxLayoutAlgorithm().LayoutWindow(self
, self
.remainingSpace
)
106 #---------------------------------------------------------------------------
108 def runTest(frame
, nb
, log
):
109 win
= TestSashWindow(nb
, log
)
112 #---------------------------------------------------------------------------