]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/AUI_MDI.py
fixed wxVsnprintf() to write as much as it can if the output buffer is too short
[wxWidgets.git] / wxPython / demo / AUI_MDI.py
1
2 import wx
3 import wx.aui
4
5 #----------------------------------------------------------------------
6
7
8 class ParentFrame(wx.aui.AuiMDIParentFrame):
9 def __init__(self, parent):
10 wx.aui.AuiMDIParentFrame.__init__(self, parent, -1,
11 title="AuiMDIParentFrame",
12 size=(640,480),
13 style=wx.DEFAULT_FRAME_STYLE)
14 self.count = 0
15 mb = self.MakeMenuBar()
16 self.SetMenuBar(mb)
17 self.CreateStatusBar()
18
19 def MakeMenuBar(self):
20 mb = wx.MenuBar()
21 menu = wx.Menu()
22 item = menu.Append(-1, "New child window\tCtrl-N")
23 self.Bind(wx.EVT_MENU, self.OnNewChild, item)
24 item = menu.Append(-1, "Close parent")
25 self.Bind(wx.EVT_MENU, self.OnDoClose, item)
26 mb.Append(menu, "&File")
27 return mb
28
29 def OnNewChild(self, evt):
30 self.count += 1
31 child = ChildFrame(self, self.count)
32 child.Show()
33
34 def OnDoClose(self, evt):
35 self.Close()
36
37
38 #----------------------------------------------------------------------
39
40 class ChildFrame(wx.aui.AuiMDIChildFrame):
41 def __init__(self, parent, count):
42 wx.aui.AuiMDIChildFrame.__init__(self, parent, -1,
43 title="Child: %d" % count)
44 mb = parent.MakeMenuBar()
45 menu = wx.Menu()
46 item = menu.Append(-1, "This is child %d's menu" % count)
47 mb.Append(menu, "&Child")
48 self.SetMenuBar(mb)
49
50 p = wx.Panel(self)
51 wx.StaticText(p, -1, "This is child %d" % count, (10,10))
52 p.SetBackgroundColour('light blue')
53
54 sizer = wx.BoxSizer()
55 sizer.Add(p, 1, wx.EXPAND)
56 self.SetSizer(sizer)
57
58 wx.CallAfter(self.Layout)
59
60 #----------------------------------------------------------------------
61
62 class TestPanel(wx.Panel):
63 def __init__(self, parent, log):
64 self.log = log
65 wx.Panel.__init__(self, parent, -1)
66
67 b = wx.Button(self, -1, "Show a AuiMDIParentFrame", (50,50))
68 self.Bind(wx.EVT_BUTTON, self.OnButton, b)
69
70
71 def OnButton(self, evt):
72 pf = ParentFrame(self)
73 pf.Show()
74
75
76
77 #----------------------------------------------------------------------
78
79 def runTest(frame, nb, log):
80 win = TestPanel(nb, log)
81 return win
82
83 #----------------------------------------------------------------------
84
85
86
87 overview = """<html><body>
88 <h2><center>wx.aui.AuiMDI</center></h2>
89
90 The wx.aui.AuiMDIParentFrame and wx.aui.AuiMDIChildFrame classes
91 implement the same API as wx.MDIParentFrame and wx.MDIChildFrame, but
92 implement the multiple document interface with a wx.aui.AuiNotebook.
93
94
95 </body></html>
96 """
97
98
99
100 if __name__ == '__main__':
101 import sys,os
102 import run
103 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
104