]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MDIDemo.py
focus setting must be possible even when not shown yet
[wxWidgets.git] / wxPython / demo / MDIDemo.py
1 #!/usr/bin/env python
2
3 from wxPython.wx import *
4 from wxScrolledWindow import MyCanvas
5
6 import images
7 SHOW_BACKGROUND = 1
8
9 #----------------------------------------------------------------------
10
11 class MyParentFrame(wxMDIParentFrame):
12 def __init__(self):
13 wxMDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400))
14
15 self.winCount = 0
16 menu = wxMenu()
17 menu.Append(5000, "&New Window")
18 menu.AppendSeparator()
19 menu.Append(5001, "E&xit")
20
21 menubar = wxMenuBar()
22 menubar.Append(menu, "&File")
23 self.SetMenuBar(menubar)
24
25 self.CreateStatusBar()
26
27 EVT_MENU(self, 5000, self.OnNewWindow)
28 EVT_MENU(self, 5001, self.OnExit)
29
30 if SHOW_BACKGROUND:
31 self.bg_bmp = images.getGridBGBitmap()
32 EVT_ERASE_BACKGROUND(self.GetClientWindow(), self.OnEraseBackground)
33
34
35 def OnExit(self, evt):
36 self.Close(True)
37
38
39 def OnNewWindow(self, evt):
40 self.winCount = self.winCount + 1
41 win = wxMDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
42 canvas = MyCanvas(win)
43 win.Show(True)
44
45
46 def OnEraseBackground(self, evt):
47 dc = evt.GetDC()
48 if not dc:
49 dc = wxClientDC(self.GetClientWindow())
50
51 # tile the background bitmap
52 sz = self.GetClientSize()
53 w = self.bg_bmp.GetWidth()
54 h = self.bg_bmp.GetHeight()
55 x = 0
56 while x < sz.width:
57 y = 0
58 while y < sz.height:
59 dc.DrawBitmap(self.bg_bmp, x, y)
60 y = y + h
61 x = x + w
62
63
64 #----------------------------------------------------------------------
65
66 if __name__ == '__main__':
67 class MyApp(wxApp):
68 def OnInit(self):
69 wxInitAllImageHandlers()
70 frame = MyParentFrame()
71 frame.Show(True)
72 self.SetTopWindow(frame)
73 return True
74
75
76 app = MyApp(0)
77 app.MainLoop()
78
79
80