]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/MDIDemo.py
fix text scrolling in GTK2 (patch 703988)
[wxWidgets.git] / wxPython / demo / MDIDemo.py
index 6251ec4a41b5cb4dad84e9f0b4e3678d6585d12e..c5298129c1ff892db66775494884d31691934118 100644 (file)
@@ -3,6 +3,9 @@
 from wxPython.wx import *
 from wxScrolledWindow import MyCanvas
 
+import images
+SHOW_BACKGROUND = 1
+
 #----------------------------------------------------------------------
 
 class MyParentFrame(wxMDIParentFrame):
@@ -24,30 +27,54 @@ class MyParentFrame(wxMDIParentFrame):
         EVT_MENU(self, 5000, self.OnNewWindow)
         EVT_MENU(self, 5001, self.OnExit)
 
+        if SHOW_BACKGROUND:
+            self.bg_bmp = images.getGridBGBitmap()
+            EVT_ERASE_BACKGROUND(self.GetClientWindow(), self.OnEraseBackground)
+
 
     def OnExit(self, evt):
-        self.Close(true)
+        self.Close(True)
 
 
     def OnNewWindow(self, evt):
         self.winCount = self.winCount + 1
         win = wxMDIChildFrame(self, -1, "Child Window: %d" % self.winCount)
         canvas = MyCanvas(win)
-        win.Show(true)
+        win.Show(True)
+
+
+    def OnEraseBackground(self, evt):
+        dc = evt.GetDC()
+        if not dc:
+            dc = wxClientDC(self.GetClientWindow())
+
+        # tile the background bitmap
+        sz = self.GetClientSize()
+        w = self.bg_bmp.GetWidth()
+        h = self.bg_bmp.GetHeight()
+        x = 0
+        while x < sz.width:
+            y = 0
+            while y < sz.height:
+                dc.DrawBitmap(self.bg_bmp, x, y)
+                y = y + h
+            x = x + w
 
 
 #----------------------------------------------------------------------
 
-class MyApp(wxApp):
-    def OnInit(self):
-        frame = MyParentFrame()
-        frame.Show(true)
-        self.SetTopWindow(frame)
-        return true
+if __name__ == '__main__':
+    class MyApp(wxApp):
+        def OnInit(self):
+            wxInitAllImageHandlers()
+            frame = MyParentFrame()
+            frame.Show(True)
+            self.SetTopWindow(frame)
+            return True
 
 
-app = MyApp(0)
-app.MainLoop()
+    app = MyApp(0)
+    app.MainLoop()