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