]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/MDIDemo.py
Shell Script file to copy setup.h for ProjectBuilder
[wxWidgets.git] / wxPython / demo / MDIDemo.py
CommitLineData
06c0fba4
RD
1#!/usr/bin/env python
2
3from wxPython.wx import *
4from wxScrolledWindow import MyCanvas
5
1e4a197e
RD
6import images
7SHOW_BACKGROUND = 1
8
06c0fba4
RD
9#----------------------------------------------------------------------
10
11class 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
de20db99 25 self.CreateStatusBar()
06c0fba4
RD
26
27 EVT_MENU(self, 5000, self.OnNewWindow)
28 EVT_MENU(self, 5001, self.OnExit)
29
1e4a197e
RD
30 if SHOW_BACKGROUND:
31 self.bg_bmp = images.getGridBGBitmap()
32 EVT_ERASE_BACKGROUND(self.GetClientWindow(), self.OnEraseBackground)
33
06c0fba4
RD
34
35 def OnExit(self, evt):
1e4a197e 36 self.Close(True)
06c0fba4
RD
37
38
39 def OnNewWindow(self, evt):
40 self.winCount = self.winCount + 1
41 win = wxMDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
f6bcfd97 42 canvas = MyCanvas(win)
1e4a197e
RD
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
06c0fba4
RD
62
63
64#----------------------------------------------------------------------
65
9c67cbec
RD
66if __name__ == '__main__':
67 class MyApp(wxApp):
68 def OnInit(self):
4d5a7477 69 wxInitAllImageHandlers()
9c67cbec 70 frame = MyParentFrame()
1e4a197e 71 frame.Show(True)
9c67cbec 72 self.SetTopWindow(frame)
1e4a197e 73 return True
06c0fba4
RD
74
75
9c67cbec
RD
76 app = MyApp(0)
77 app.MainLoop()
06c0fba4
RD
78
79
80