3 from wxPython
.wx
import *
4 from wxScrolledWindow
import MyCanvas
6 #----------------------------------------------------------------------
8 class MyParentFrame(wxMDIParentFrame
):
10 ID_WINDOW_LEFT1
= 5101
11 ID_WINDOW_LEFT2
= 5102
12 ID_WINDOW_BOTTOM
= 5103
15 wxMDIParentFrame
.__init
__(self
, None, -1, "MDI Parent", size
=(600,400),
16 style
= wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL
)
20 menu
.Append(5000, "&New Window")
21 menu
.AppendSeparator()
22 menu
.Append(5001, "E&xit")
25 menubar
.Append(menu
, "&File")
26 self
.SetMenuBar(menubar
)
28 #self.CreateStatusBar()
30 EVT_MENU(self
, 5000, self
.OnNewWindow
)
31 EVT_MENU(self
, 5001, self
.OnExit
)
34 EVT_SASH_DRAGGED_RANGE(self
,
35 self
.ID_WINDOW_TOP
, self
.ID_WINDOW_BOTTOM
,
37 EVT_SIZE(self
, self
.OnSize
)
40 # Create some layout windows
41 # A window like a toolbar
42 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_TOP
, style
= wxNO_BORDER|wxSW_3D
)
43 win
.SetDefaultSize((1000, 30))
44 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
45 win
.SetAlignment(wxLAYOUT_TOP
)
46 win
.SetBackgroundColour(wxColour(255, 0, 0))
47 win
.SetSashVisible(wxSASH_BOTTOM
, True)
52 # A window like a statusbar
53 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_BOTTOM
, style
= wxNO_BORDER|wxSW_3D
)
54 win
.SetDefaultSize((1000, 30))
55 win
.SetOrientation(wxLAYOUT_HORIZONTAL
)
56 win
.SetAlignment(wxLAYOUT_BOTTOM
)
57 win
.SetBackgroundColour(wxColour(0, 0, 255))
58 win
.SetSashVisible(wxSASH_TOP
, True)
60 self
.bottomWindow
= win
63 # A window to the left of the client window
64 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT1
, style
= wxNO_BORDER|wxSW_3D
)
65 win
.SetDefaultSize((120, 1000))
66 win
.SetOrientation(wxLAYOUT_VERTICAL
)
67 win
.SetAlignment(wxLAYOUT_LEFT
)
68 win
.SetBackgroundColour(wxColour(0, 255, 0))
69 win
.SetSashVisible(wxSASH_RIGHT
, True)
70 win
.SetExtraBorderSize(10)
71 textWindow
= wxTextCtrl(win
, -1, "", wxDefaultPosition
, wxDefaultSize
,
72 wxTE_MULTILINE|wxSUNKEN_BORDER
)
73 textWindow
.SetValue("A sub window")
75 self
.leftWindow1
= win
78 # Another window to the left of the client window
79 win
= wxSashLayoutWindow(self
, self
.ID_WINDOW_LEFT2
, style
= wxNO_BORDER|wxSW_3D
)
80 win
.SetDefaultSize((120, 1000))
81 win
.SetOrientation(wxLAYOUT_VERTICAL
)
82 win
.SetAlignment(wxLAYOUT_LEFT
)
83 win
.SetBackgroundColour(wxColour(0, 255, 255))
84 win
.SetSashVisible(wxSASH_RIGHT
, True)
86 self
.leftWindow2
= win
89 def OnSashDrag(self
, event
):
90 if event
.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE
:
94 if eID
== self
.ID_WINDOW_TOP
:
95 self
.topWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
97 elif eID
== self
.ID_WINDOW_LEFT1
:
98 self
.leftWindow1
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
101 elif eID
== self
.ID_WINDOW_LEFT2
:
102 self
.leftWindow2
.SetDefaultSize(wxSize(event
.GetDragRect().width
, 1000))
104 elif eID
== self
.ID_WINDOW_BOTTOM
:
105 self
.bottomWindow
.SetDefaultSize(wxSize(1000, event
.GetDragRect().height
))
107 wxLayoutAlgorithm().LayoutMDIFrame(self
)
108 self
.GetClientWindow().Refresh()
111 def OnSize(self
, event
):
112 wxLayoutAlgorithm().LayoutMDIFrame(self
)
115 def OnExit(self
, evt
):
119 def OnNewWindow(self
, evt
):
120 self
.winCount
= self
.winCount
+ 1
121 win
= wxMDIChildFrame(self
, -1, "Child Window: %d" % self
.winCount
)
122 canvas
= MyCanvas(win
)
126 #----------------------------------------------------------------------
128 if __name__
== '__main__':
131 wxInitAllImageHandlers()
132 frame
= MyParentFrame()
134 self
.SetTopWindow(frame
)