]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MDISashDemo.py
corrections for compilation under Mac OS X
[wxWidgets.git] / wxPython / demo / MDISashDemo.py
1 #!/usr/bin/env python
2
3 from wxPython.wx import *
4 from wxScrolledWindow import MyCanvas
5
6 #----------------------------------------------------------------------
7
8 class MyParentFrame(wxMDIParentFrame):
9 ID_WINDOW_TOP = 5100
10 ID_WINDOW_LEFT1 = 5101
11 ID_WINDOW_LEFT2 = 5102
12 ID_WINDOW_BOTTOM = 5103
13
14 def __init__(self):
15 wxMDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400),
16 style = wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL)
17
18 self.winCount = 0
19 menu = wxMenu()
20 menu.Append(5000, "&New Window")
21 menu.AppendSeparator()
22 menu.Append(5001, "E&xit")
23
24 menubar = wxMenuBar()
25 menubar.Append(menu, "&File")
26 self.SetMenuBar(menubar)
27
28 #self.CreateStatusBar()
29
30 EVT_MENU(self, 5000, self.OnNewWindow)
31 EVT_MENU(self, 5001, self.OnExit)
32
33
34 EVT_SASH_DRAGGED_RANGE(self,
35 self.ID_WINDOW_TOP, self.ID_WINDOW_BOTTOM,
36 self.OnSashDrag)
37 EVT_SIZE(self, self.OnSize)
38
39
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)
48
49 self.topWindow = win
50
51
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)
59
60 self.bottomWindow = win
61
62
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")
74
75 self.leftWindow1 = win
76
77
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)
85
86 self.leftWindow2 = win
87
88
89 def OnSashDrag(self, event):
90 if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
91 return
92
93 eID = event.GetId()
94 if eID == self.ID_WINDOW_TOP:
95 self.topWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
96
97 elif eID == self.ID_WINDOW_LEFT1:
98 self.leftWindow1.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
99
100
101 elif eID == self.ID_WINDOW_LEFT2:
102 self.leftWindow2.SetDefaultSize(wxSize(event.GetDragRect().width, 1000))
103
104 elif eID == self.ID_WINDOW_BOTTOM:
105 self.bottomWindow.SetDefaultSize(wxSize(1000, event.GetDragRect().height))
106
107 wxLayoutAlgorithm().LayoutMDIFrame(self)
108 self.GetClientWindow().Refresh()
109
110
111 def OnSize(self, event):
112 wxLayoutAlgorithm().LayoutMDIFrame(self)
113
114
115 def OnExit(self, evt):
116 self.Close(True)
117
118
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)
123 win.Show(True)
124
125
126 #----------------------------------------------------------------------
127
128 if __name__ == '__main__':
129 class MyApp(wxApp):
130 def OnInit(self):
131 wxInitAllImageHandlers()
132 frame = MyParentFrame()
133 frame.Show(True)
134 self.SetTopWindow(frame)
135 return True
136
137
138 app = MyApp(0)
139 app.MainLoop()
140
141
142