2003-12-08 20:23:28 -05:00
|
|
|
|
|
|
|
import wx
|
|
|
|
|
2004-01-02 20:14:17 -05:00
|
|
|
# Importing ScrolledWindow demo to make use of the MyCanvas
|
2003-12-08 20:23:28 -05:00
|
|
|
# class defined within.
|
2004-01-02 20:14:17 -05:00
|
|
|
import ScrolledWindow
|
2003-12-08 20:23:28 -05:00
|
|
|
import images
|
1999-10-09 17:24:16 -04:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
SHOW_BACKGROUND = 1
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
ID_New = wx.NewId()
|
|
|
|
ID_Exit = wx.NewId()
|
1999-10-09 17:24:16 -04:00
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
class MyParentFrame(wx.MDIParentFrame):
|
1999-10-09 17:24:16 -04:00
|
|
|
def __init__(self):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.MDIParentFrame.__init__(self, None, -1, "MDI Parent", size=(600,400))
|
1999-10-09 17:24:16 -04:00
|
|
|
|
|
|
|
self.winCount = 0
|
2003-12-08 20:23:28 -05:00
|
|
|
menu = wx.Menu()
|
|
|
|
menu.Append(ID_New, "&New Window")
|
1999-10-09 17:24:16 -04:00
|
|
|
menu.AppendSeparator()
|
2003-12-08 20:23:28 -05:00
|
|
|
menu.Append(ID_Exit, "E&xit")
|
1999-10-09 17:24:16 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
menubar = wx.MenuBar()
|
1999-10-09 17:24:16 -04:00
|
|
|
menubar.Append(menu, "&File")
|
|
|
|
self.SetMenuBar(menubar)
|
|
|
|
|
2000-12-10 03:37:52 -05:00
|
|
|
self.CreateStatusBar()
|
1999-10-09 17:24:16 -04:00
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
self.Bind(wx.EVT_MENU, self.OnNewWindow, id=ID_New)
|
|
|
|
self.Bind(wx.EVT_MENU, self.OnExit, id=ID_Exit)
|
1999-10-09 17:24:16 -04:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
if SHOW_BACKGROUND:
|
|
|
|
self.bg_bmp = images.getGridBGBitmap()
|
2003-12-08 20:23:28 -05:00
|
|
|
self.GetClientWindow().Bind(
|
|
|
|
wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground
|
|
|
|
)
|
2003-03-25 01:35:27 -05:00
|
|
|
|
1999-10-09 17:24:16 -04:00
|
|
|
|
|
|
|
def OnExit(self, evt):
|
2003-03-25 01:35:27 -05:00
|
|
|
self.Close(True)
|
1999-10-09 17:24:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
def OnNewWindow(self, evt):
|
|
|
|
self.winCount = self.winCount + 1
|
2003-12-08 20:23:28 -05:00
|
|
|
win = wx.MDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
|
2004-01-02 20:14:17 -05:00
|
|
|
canvas = ScrolledWindow.MyCanvas(win)
|
2003-03-25 01:35:27 -05:00
|
|
|
win.Show(True)
|
|
|
|
|
|
|
|
|
|
|
|
def OnEraseBackground(self, evt):
|
|
|
|
dc = evt.GetDC()
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
if not dc:
|
2003-12-08 20:23:28 -05:00
|
|
|
dc = wx.ClientDC(self.GetClientWindow())
|
2003-03-25 01:35:27 -05:00
|
|
|
|
|
|
|
# tile the background bitmap
|
|
|
|
sz = self.GetClientSize()
|
|
|
|
w = self.bg_bmp.GetWidth()
|
|
|
|
h = self.bg_bmp.GetHeight()
|
|
|
|
x = 0
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
while x < sz.width:
|
|
|
|
y = 0
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
while y < sz.height:
|
2004-05-01 22:41:33 -04:00
|
|
|
dc.DrawBitmap(self.bg_bmp, x, y)
|
2003-03-25 01:35:27 -05:00
|
|
|
y = y + h
|
2003-12-08 20:23:28 -05:00
|
|
|
|
2003-03-25 01:35:27 -05:00
|
|
|
x = x + w
|
1999-10-09 17:24:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
#----------------------------------------------------------------------
|
|
|
|
|
2002-04-18 01:43:08 -04:00
|
|
|
if __name__ == '__main__':
|
2003-12-08 20:23:28 -05:00
|
|
|
class MyApp(wx.App):
|
2002-04-18 01:43:08 -04:00
|
|
|
def OnInit(self):
|
2003-12-08 20:23:28 -05:00
|
|
|
wx.InitAllImageHandlers()
|
2002-04-18 01:43:08 -04:00
|
|
|
frame = MyParentFrame()
|
2003-03-25 01:35:27 -05:00
|
|
|
frame.Show(True)
|
2002-04-18 01:43:08 -04:00
|
|
|
self.SetTopWindow(frame)
|
2003-03-25 01:35:27 -05:00
|
|
|
return True
|
1999-10-09 17:24:16 -04:00
|
|
|
|
|
|
|
|
2003-12-08 20:23:28 -05:00
|
|
|
app = MyApp(False)
|
2002-04-18 01:43:08 -04:00
|
|
|
app.MainLoop()
|
1999-10-09 17:24:16 -04:00
|
|
|
|
|
|
|
|
|
|
|
|