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