]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/Grid_MegaExample.py
Some wxCollapsiblePane tweaks:
[wxWidgets.git] / wxPython / demo / Grid_MegaExample.py
index 751e7ab2916fd2414ec5e1edbba21e18bae4c184..0a7f0c590cda6f2f4fede146690ff50bbb1671e5 100644 (file)
@@ -1,16 +1,14 @@
-# 11/18/2003 - Jeff Grimmett (grimmtooth@softhome.net)
-#
-# o Updated for wx namespace
-# 
 
 import  wx
 import  wx.grid as  Grid
 
 import  images
 
 
 import  wx
 import  wx.grid as  Grid
 
 import  images
 
+#---------------------------------------------------------------------------
+
 class MegaTable(Grid.PyGridTableBase):
     """
 class MegaTable(Grid.PyGridTableBase):
     """
-    A custom wxGrid Table using user supplied data
+    A custom wx.Grid Table using user supplied data
     """
     def __init__(self, data, colnames, plugins):
         """data is a list of the form
     """
     def __init__(self, data, colnames, plugins):
         """data is a list of the form
@@ -90,7 +88,7 @@ class MegaTable(Grid.PyGridTableBase):
 
     def _updateColAttrs(self, grid):
         """
 
     def _updateColAttrs(self, grid):
         """
-        wxGrid -> update the column attributes to add the
+        wx.Grid -> update the column attributes to add the
         appropriate renderer given the column name.  (renderers
         are stored in the self.plugins dictionary)
 
         appropriate renderer given the column name.  (renderers
         are stored in the self.plugins dictionary)
 
@@ -187,7 +185,7 @@ class MegaTable(Grid.PyGridTableBase):
 
 
 # --------------------------------------------------------------------
 
 
 # --------------------------------------------------------------------
-# Sample wxGrid renderers
+# Sample wx.Grid renderers
 
 class MegaImageRenderer(Grid.PyGridCellRenderer):
     def __init__(self, table):
 
 class MegaImageRenderer(Grid.PyGridCellRenderer):
     def __init__(self, table):
@@ -200,8 +198,8 @@ class MegaImageRenderer(Grid.PyGridCellRenderer):
         self.table = table
         self._choices = [images.getSmilesBitmap,
                          images.getMondrianBitmap,
         self.table = table
         self._choices = [images.getSmilesBitmap,
                          images.getMondrianBitmap,
-                         images.get_10s_Bitmap,
-                         images.get_01c_Bitmap]
+                         images.getWXPdemoBitmap,
+                         ]
 
         self.colSize = None
         self.rowSize = None
 
         self.colSize = None
         self.rowSize = None
@@ -223,7 +221,6 @@ class MegaImageRenderer(Grid.PyGridCellRenderer):
             dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
         dc.DrawRectangleRect(rect)
 
             dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
         dc.DrawRectangleRect(rect)
 
-        #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
 
         # copy the image but only to the size of the grid cell
         width, height = bmp.GetWidth(), bmp.GetHeight()
 
         # copy the image but only to the size of the grid cell
         width, height = bmp.GetWidth(), bmp.GetHeight()
@@ -234,9 +231,9 @@ class MegaImageRenderer(Grid.PyGridCellRenderer):
         if height > rect.height-2:
             height = rect.height-2
 
         if height > rect.height-2:
             height = rect.height-2
 
-        dc.Blit((rect.x+1, rect.y+1), (width, height),
+        dc.Blit(rect.x+1, rect.y+1, width, height,
                 image,
                 image,
-                (0, 0), wx.COPY, True)
+                0, 0, wx.COPY, True)
 
 
 class MegaFontRenderer(Grid.PyGridCellRenderer):
 
 
 class MegaFontRenderer(Grid.PyGridCellRenderer):
@@ -269,8 +266,6 @@ class MegaFontRenderer(Grid.PyGridCellRenderer):
             dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
         dc.DrawRectangleRect(rect)
 
             dc.SetPen(wx.Pen(wx.WHITE, 1, wx.SOLID))
         dc.DrawRectangleRect(rect)
 
-        #dc.DrawRectangle((rect.x, rect.y), (rect.width, rect.height))
-
         text = self.table.GetValue(row, col)
         dc.SetBackgroundMode(wx.SOLID)
 
         text = self.table.GetValue(row, col)
         dc.SetBackgroundMode(wx.SOLID)
 
@@ -285,7 +280,7 @@ class MegaFontRenderer(Grid.PyGridCellRenderer):
 
         dc.SetTextForeground(self.color)
         dc.SetFont(self.font)
 
         dc.SetTextForeground(self.color)
         dc.SetFont(self.font)
-        dc.DrawText(text, (rect.x+1, rect.y+1))
+        dc.DrawText(text, rect.x+1, rect.y+1)
 
         # Okay, now for the advanced class :)
         # Let's add three dots "..."
 
         # Okay, now for the advanced class :)
         # Let's add three dots "..."
@@ -297,8 +292,8 @@ class MegaFontRenderer(Grid.PyGridCellRenderer):
         if width > rect.width-2:
             width, height = dc.GetTextExtent("...")
             x = rect.x+1 + rect.width-2 - width
         if width > rect.width-2:
             width, height = dc.GetTextExtent("...")
             x = rect.x+1 + rect.width-2 - width
-            dc.DrawRectangle((x, rect.y+1), (width+1, height))
-            dc.DrawText("...", (x, rect.y+1))
+            dc.DrawRectangle(x, rect.y+1, width+1, height)
+            dc.DrawText("...", x, rect.y+1)
 
         dc.DestroyClippingRegion()
 
 
         dc.DestroyClippingRegion()
 
@@ -359,7 +354,7 @@ class MegaGrid(Grid.Grid):
 
         self.Bind(wx.EVT_MENU, append, id=appendID)
         self.Bind(wx.EVT_MENU, delete, id=deleteID)
 
         self.Bind(wx.EVT_MENU, append, id=appendID)
         self.Bind(wx.EVT_MENU, delete, id=deleteID)
-        self.PopupMenu(menu, (x, yo))
+        self.PopupMenu(menu)
         menu.Destroy()
         return
 
         menu.Destroy()
         return
 
@@ -393,7 +388,7 @@ class MegaGrid(Grid.Grid):
         if len(cols) == 1:
             self.Bind(wx.EVT_MENU, sort, id=sortID)
 
         if len(cols) == 1:
             self.Bind(wx.EVT_MENU, sort, id=sortID)
 
-        self.PopupMenu(menu, (xo, 0))
+        self.PopupMenu(menu)
         menu.Destroy()
         return
 
         menu.Destroy()
         return
 
@@ -451,10 +446,25 @@ class TestFrame(wx.Frame):
 
 #---------------------------------------------------------------------------
 
 
 #---------------------------------------------------------------------------
 
+class TestPanel(wx.Panel):
+    def __init__(self, parent, log):
+        self.log = log
+        wx.Panel.__init__(self, parent, -1)
+
+        b = wx.Button(self, -1, "Show the MegaGrid", (50,50))
+        self.Bind(wx.EVT_BUTTON, self.OnButton, b)
+
+
+    def OnButton(self, evt):
+        win = TestFrame(self)
+        win.Show(True)
+
+#---------------------------------------------------------------------------
+
+
 def runTest(frame, nb, log):
 def runTest(frame, nb, log):
-    win = TestFrame(frame)
-    frame.otherWin = win
-    win.Show(True)
+    win = TestPanel(nb, log)
+    return win
 
 
 
 
 
 
@@ -483,5 +493,5 @@ behavior and various hacks.
 if __name__ == '__main__':
     import sys,os
     import run
 if __name__ == '__main__':
     import sys,os
     import run
-    run.main(['', os.path.basename(sys.argv[0])])
+    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])