]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MDISashDemo.py
3 # 11/6/2003 - Jeff Grimmett (grimmtooth@softhome.net)
5 # o Updated for wx namespace
12 #----------------------------------------------------------------------
13 # There are better ways to do IDs, but this demo requires that the window
14 # IDs be in a specific range. There are better ways to do that, too, but
15 # this will do for purposes of this demo.
21 ID_WINDOW_LEFT1
= 5001
22 ID_WINDOW_LEFT2
= 5002
23 ID_WINDOW_BOTTOM
= 5003
25 #----------------------------------------------------------------------
27 class MyParentFrame(wx
.MDIParentFrame
):
29 wx
.MDIParentFrame
.__init
__(
30 self
, None, -1, "MDI Parent", size
=(600,400),
31 style
= wx
.DEFAULT_FRAME_STYLE | wx
.HSCROLL | wx
.VSCROLL
36 menu
.Append(ID_Menu_New
, "&New Window")
37 menu
.AppendSeparator()
38 menu
.Append(ID_Menu_Exit
, "E&xit")
40 menubar
= wx
.MenuBar()
41 menubar
.Append(menu
, "&File")
42 self
.SetMenuBar(menubar
)
44 #self.CreateStatusBar()
46 self
.Bind(wx
.EVT_MENU
, self
.OnNewWindow
, id=ID_Menu_New
)
47 self
.Bind(wx
.EVT_MENU
, self
.OnExit
, id=ID_Menu_Exit
)
50 wx
.EVT_SASH_DRAGGED_RANGE
, self
.OnSashDrag
, id=ID_WINDOW_TOP
,
54 self
.Bind(wx
.EVT_SIZE
, self
.OnSize
)
57 # Create some layout windows
58 # A window like a toolbar
59 win
= wx
.SashLayoutWindow(self
, ID_WINDOW_TOP
, style
=wx
.NO_BORDER|wx
.SW_3D
)
60 win
.SetDefaultSize((1000, 30))
61 win
.SetOrientation(wx
.LAYOUT_HORIZONTAL
)
62 win
.SetAlignment(wx
.LAYOUT_TOP
)
63 win
.SetBackgroundColour(wx
.Colour(255, 0, 0))
64 win
.SetSashVisible(wx
.SASH_BOTTOM
, True)
69 # A window like a statusbar
70 win
= wx
.SashLayoutWindow(self
, ID_WINDOW_BOTTOM
, style
=wx
.NO_BORDER|wx
.SW_3D
)
71 win
.SetDefaultSize((1000, 30))
72 win
.SetOrientation(wx
.LAYOUT_HORIZONTAL
)
73 win
.SetAlignment(wx
.LAYOUT_BOTTOM
)
74 win
.SetBackgroundColour(wx
.Colour(0, 0, 255))
75 win
.SetSashVisible(wx
.SASH_TOP
, True)
77 self
.bottomWindow
= win
80 # A window to the left of the client window
81 win
= wx
.SashLayoutWindow(self
, ID_WINDOW_LEFT1
, style
=wx
.NO_BORDER|wx
.SW_3D
)
82 win
.SetDefaultSize((120, 1000))
83 win
.SetOrientation(wx
.LAYOUT_VERTICAL
)
84 win
.SetAlignment(wx
.LAYOUT_LEFT
)
85 win
.SetBackgroundColour(wx
.Colour(0, 255, 0))
86 win
.SetSashVisible(wx
.SASH_RIGHT
, True)
87 win
.SetExtraBorderSize(10)
88 textWindow
= wx
.TextCtrl(win
, -1, "", style
=wx
.TE_MULTILINE|wx
.SUNKEN_BORDER
)
89 textWindow
.SetValue("A sub window")
91 self
.leftWindow1
= win
94 # Another window to the left of the client window
95 win
= wx
.SashLayoutWindow(self
, ID_WINDOW_LEFT2
, style
=wx
.NO_BORDER|wx
.SW_3D
)
96 win
.SetDefaultSize((120, 1000))
97 win
.SetOrientation(wx
.LAYOUT_VERTICAL
)
98 win
.SetAlignment(wx
.LAYOUT_LEFT
)
99 win
.SetBackgroundColour(wx
.Colour(0, 255, 255))
100 win
.SetSashVisible(wx
.SASH_RIGHT
, True)
102 self
.leftWindow2
= win
105 def OnSashDrag(self
, event
):
106 if event
.GetDragStatus() == wx
.SASH_STATUS_OUT_OF_RANGE
:
111 if eID
== ID_WINDOW_TOP
:
112 self
.topWindow
.SetDefaultSize((1000, event
.GetDragRect().height
))
114 elif eID
== ID_WINDOW_LEFT1
:
115 self
.leftWindow1
.SetDefaultSize((event
.GetDragRect().width
, 1000))
117 elif eID
== ID_WINDOW_LEFT2
:
118 self
.leftWindow2
.SetDefaultSize((event
.GetDragRect().width
, 1000))
120 elif eID
== ID_WINDOW_BOTTOM
:
121 self
.bottomWindow
.SetDefaultSize((1000, event
.GetDragRect().height
))
123 wx
.LayoutAlgorithm().LayoutMDIFrame(self
)
124 self
.GetClientWindow().Refresh()
127 def OnSize(self
, event
):
128 wx
.LayoutAlgorithm().LayoutMDIFrame(self
)
131 def OnExit(self
, evt
):
135 def OnNewWindow(self
, evt
):
136 self
.winCount
= self
.winCount
+ 1
137 win
= wx
.MDIChildFrame(self
, -1, "Child Window: %d" % self
.winCount
)
138 canvas
= ScrolledWindow
.MyCanvas(win
)
142 #----------------------------------------------------------------------
144 if __name__
== '__main__':
147 wx
.InitAllImageHandlers()
148 frame
= MyParentFrame()
150 self
.SetTopWindow(frame
)