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
)
22 # Create some layout windows
23 # A window like a toolbar
24 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_TOP
, wxDefaultPosition
,
25 wxSize(200, 30), wxNO_BORDER|wxSW_3D
)
26 win
.SetDefaultSize(wxSize(1000, 30))
27 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
28 win
.SetAlignment(wxLAYOUT_TOP
)
29 win
.SetBackgroundColour(wxColour(255, 0, 0))
30 win
.SetSashVisible(wxSASH_BOTTOM
, true
)
35 # A window like a statusbar
36 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_BOTTOM
,
37 wxDefaultPosition
, wxSize(200, 30),
39 win
.SetDefaultSize(wxSize(1000, 30))
40 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
41 win
.SetAlignment(wxLAYOUT_BOTTOM
)
42 win
.SetBackgroundColour(wxColour(0, 0, 255))
43 win
.SetSashVisible(wxSASH_TOP
, true
)
45 self
.bottomWindow
= win
48 # A window to the left of the client window
49 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT1
,
50 wxDefaultPosition
, wxSize(200, 30),
52 win
.SetDefaultSize(wxSize(120, 1000))
53 win
.SetOrientation(wxLAYOUT_VERTICAL
)
54 win
.SetAlignment(wxLAYOUT_LEFT
)
55 win
.SetBackgroundColour(wxColour(0, 255, 0))
56 win
.SetSashVisible(wxSASH_RIGHT
, TRUE
)
57 win
.SetExtraBorderSize(10)
59 textWindow
= wxTextCtrl(win
, -1, "", wxDefaultPosition
, wxDefaultSize
,
60 wxTE_MULTILINE|wxSUNKEN_BORDER
)
61 textWindow
.SetValue("A help window")
63 self
.leftWindow1
= win
66 # Another window to the left of the client window
67 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT2
,
68 wxDefaultPosition
, wxSize(200, 30),
70 win
.SetDefaultSize(wxSize(120, 1000))
71 win
.SetOrientation(wxLAYOUT_VERTICAL
)
72 win
.SetAlignment(wxLAYOUT_LEFT
)
73 win
.SetBackgroundColour(wxColour(0, 255, 255))
74 win
.SetSashVisible(wxSASH_RIGHT
, TRUE
)
76 self
.leftWindow2
= win
79 def OnSashDrag(self
, event
):
80 if event
.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE
:
84 if eID
== self
.ID_WINDOW_TOP
:
85 self
.topWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
87 elif eID
== self
.ID_WINDOW_LEFT1
:
88 self
.leftWindow1
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
91 elif eID
== self
.ID_WINDOW_LEFT2
:
92 self
.leftWindow2
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
94 elif eID
== self
.ID_WINDOW_BOTTOM
:
95 self
.bottomWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
97 wxLayoutAlgorithm().LayoutWindow(self
)
100 def OnSize(self
, event
):
101 wxLayoutAlgorithm().LayoutWindow(self
)
103 #---------------------------------------------------------------------------
105 def runTest(frame
, nb
, log
):
106 win
= TestSashWindow(nb
, log
)
109 #---------------------------------------------------------------------------
127 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.
130 -------------------------------------------
134 wxSashLayoutWindow(wxSashLayoutWindow* parent, wxSashLayoutWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxCLIP_CHILDREN | wxSW_3D, const wxString& name = "layoutWindow")
136 Constructs a sash layout window, which can be a child of a frame, dialog or any other non-control window.
141 parent = Pointer to a parent window.
143 id = Window identifier. If -1, will automatically create an identifier.
145 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.
147 size = Window size. wxDefaultSize is (-1, -1) which indicates that wxSashLayoutWindows should generate a default size for the window.
149 style = Window style. For window styles, please see wxSashLayoutWindow.