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 EVT_SASH_DRAGGED_RANGE(self
, self
.ID_WINDOW_TOP
,
19 self
.ID_WINDOW_BOTTOM
, self
.OnSashDrag
)
20 EVT_SIZE(self
, self
.OnSize
)
23 # Create some layout windows
24 # A window like a toolbar
25 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_TOP
, wxDefaultPosition
,
26 wxSize(200, 30), wxNO_BORDER|wxSW_3D
)
27 win
.SetDefaultSize(wxSize(1000, 30))
28 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
29 win
.SetAlignment(wxLAYOUT_TOP
)
30 win
.SetBackgroundColour(wxColour(255, 0, 0))
31 win
.SetSashVisible(wxSASH_BOTTOM
, true
)
36 # A window like a statusbar
37 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_BOTTOM
,
38 wxDefaultPosition
, wxSize(200, 30),
40 win
.SetDefaultSize(wxSize(1000, 30))
41 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
42 win
.SetAlignment(wxLAYOUT_BOTTOM
)
43 win
.SetBackgroundColour(wxColour(0, 0, 255))
44 win
.SetSashVisible(wxSASH_TOP
, true
)
46 self
.bottomWindow
= win
49 # A window to the left of the client window
50 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT1
,
51 wxDefaultPosition
, wxSize(200, 30),
53 win
.SetDefaultSize(wxSize(120, 1000))
54 win
.SetOrientation(wxLAYOUT_VERTICAL
)
55 win
.SetAlignment(wxLAYOUT_LEFT
)
56 win
.SetBackgroundColour(wxColour(0, 255, 0))
57 win
.SetSashVisible(wxSASH_RIGHT
, TRUE
)
58 win
.SetExtraBorderSize(10)
60 textWindow
= wxTextCtrl(win
, -1, "", wxDefaultPosition
, wxDefaultSize
,
61 wxTE_MULTILINE|wxSUNKEN_BORDER
)
62 textWindow
.SetValue("A help window")
64 self
.leftWindow1
= win
67 # Another window to the left of the client window
68 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT2
,
69 wxDefaultPosition
, wxSize(200, 30),
71 win
.SetDefaultSize(wxSize(120, 1000))
72 win
.SetOrientation(wxLAYOUT_VERTICAL
)
73 win
.SetAlignment(wxLAYOUT_LEFT
)
74 win
.SetBackgroundColour(wxColour(0, 255, 255))
75 win
.SetSashVisible(wxSASH_RIGHT
, TRUE
)
77 self
.leftWindow2
= win
80 def OnSashDrag(self
, event
):
81 if event
.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE
:
85 if eID
== self
.ID_WINDOW_TOP
:
86 self
.topWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
88 elif eID
== self
.ID_WINDOW_LEFT1
:
89 self
.leftWindow1
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
92 elif eID
== self
.ID_WINDOW_LEFT2
:
93 self
.leftWindow2
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
95 elif eID
== self
.ID_WINDOW_BOTTOM
:
96 self
.bottomWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
98 wxLayoutAlgorithm().LayoutWindow(self
)
101 def OnSize(self
, event
):
102 wxLayoutAlgorithm().LayoutWindow(self
)
104 #---------------------------------------------------------------------------
106 def runTest(frame
, nb
, log
):
107 win
= TestSashWindow(nb
, log
)
110 #---------------------------------------------------------------------------
128 wxSashLayoutWindow responds to OnCalculateLayout events generated by wxLayoutAlgorithm. It allows the application to use simple accessors to specify how the window should be laid out, rather than having to respond to events. The fact that the class derives from wxSashWindow allows sashes to be used if required, to allow the windows to be user-resizable.
131 -------------------------------------------
135 wxSashLayoutWindow(wxSashLayoutWindow* parent, wxSashLayoutWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = "layoutWindow")
137 Constructs a sash layout window, which can be a child of a frame, dialog or any other non-control window.
142 parent = Pointer to a parent window.
144 id = Window identifier. If -1, will automatically create an identifier.
146 pos = Window position. wxDefaultPosition is (-1, -1) which indicates that wxSashLayoutWindows should generate a default position for the window. If using the wxSashLayoutWindow class directly, supply an actual position.
148 size = Window size. wxDefaultSize is (-1, -1) which indicates that wxSashLayoutWindows should generate a default size for the window.
150 style = Window style. For window styles, please see wxSashLayoutWindow.