]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MDIDemo.py
Aquire the GIL before raising the NotImplementedError exception
[wxWidgets.git] / wxPython / demo / MDIDemo.py
1 #!/usr/bin/env python
2
3 # 11/12/2003 - Jeff Grimmett (grimmtooth@softhome.net)
4 #
5 # o Updated for wx namespace
6 # o Replaced hardcoded menu IDs with dynamic IDs
7 #
8
9 import wx
10
11 # Importing wxScrolledWindow demo to make use of the MyCanvas
12 # class defined within.
13 import wxScrolledWindow
14 import images
15
16 SHOW_BACKGROUND = 1
17
18 #----------------------------------------------------------------------
19 ID_New = wx.NewId()
20 ID_Exit = wx.NewId()
21 #----------------------------------------------------------------------
22
23 class MyParentFrame(wx.MDIParentFrame):
24 def __init__(self):
25 wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400))
26
27 self.winCount = 0
28 menu = wx.Menu()
29 menu.Append(ID_New, "&New Window")
30 menu.AppendSeparator()
31 menu.Append(ID_Exit, "E&xit")
32
33 menubar = wx.MenuBar()
34 menubar.Append(menu, "&File")
35 self.SetMenuBar(menubar)
36
37 self.CreateStatusBar()
38
39 self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ID_New)
40 self.Bind(wx.EVT_MENU, self.OnExit, id=ID_Exit)
41
42 if SHOW_BACKGROUND:
43 self.bg_bmp = images.getGridBGBitmap()
44 self.GetClientWindow().Bind(
45 wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground
46 )
47
48
49 def OnExit(self, evt):
50 self.Close(True)
51
52
53 def OnNewWindow(self, evt):
54 self.winCount = self.winCount + 1
55 win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
56 canvas = wxScrolledWindow.MyCanvas(win)
57 win.Show(True)
58
59
60 def OnEraseBackground(self, evt):
61 dc = evt.GetDC()
62
63 if not dc:
64 dc = wx.ClientDC(self.GetClientWindow())
65
66 # tile the background bitmap
67 sz = self.GetClientSize()
68 w = self.bg_bmp.GetWidth()
69 h = self.bg_bmp.GetHeight()
70 x = 0
71
72 while x < sz.width:
73 y = 0
74
75 while y < sz.height:
76 dc.DrawBitmap(self.bg_bmp, (x, y))
77 y = y + h
78
79 x = x + w
80
81
82 #----------------------------------------------------------------------
83
84 if __name__ == '__main__':
85 class MyApp(wx.App):
86 def OnInit(self):
87 wx.InitAllImageHandlers()
88 frame = MyParentFrame()
89 frame.Show(True)
90 self.SetTopWindow(frame)
91 return True
92
93
94 app = MyApp(False)
95 app.MainLoop()
96
97
98