]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/demo/ColourDB.py
Another package name fix
[wxWidgets.git] / wxPython / demo / ColourDB.py
index 1680c31a9d8a77feba9dfe73a9b4a0c293666f11..a13d7e13b6fc049b8366462093cc1fdab2c6b0dc 100644 (file)
@@ -12,16 +12,11 @@ class TestWindow(wx.ScrolledWindow):
         wx.ScrolledWindow.__init__(self, parent, -1)
 
         # Populate our color list
         wx.ScrolledWindow.__init__(self, parent, -1)
 
         # Populate our color list
-        self.clrList = wx.lib.colourdb.getColourList()
+        self.clrList = wx.lib.colourdb.getColourInfoList()
 
         # Just for style points, we'll use this as a background image.
 
         # Just for style points, we'll use this as a background image.
-        #self.clrList.sort()
         self.bg_bmp = images.getGridBGBitmap()
 
         self.bg_bmp = images.getGridBGBitmap()
 
-        # Event handlers
-        self.Bind(wx.EVT_PAINT, self.OnPaint)
-        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
-
         # This could also be done by getting the window's default font;
         # either way, we need to have a font loaded for later on.
         #self.SetBackgroundColour("WHITE")
         # This could also be done by getting the window's default font;
         # either way, we need to have a font loaded for later on.
         #self.SetBackgroundColour("WHITE")
@@ -54,6 +49,12 @@ class TestWindow(wx.ScrolledWindow):
         self.SetScrollbars(
             self.cellWidth, self.lineHeight, numCells, len(self.clrList) + 2
             )
         self.SetScrollbars(
             self.cellWidth, self.lineHeight, numCells, len(self.clrList) + 2
             )
+            
+        # Event handlers - moved here so events won't fire before init is 
+        # finished.
+        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
+        self.Bind(wx.EVT_PAINT, self.OnPaint)
+        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
 
 
     # tile the background bitmap loaded in __init__()
 
 
     # tile the background bitmap loaded in __init__()
@@ -72,7 +73,7 @@ class TestWindow(wx.ScrolledWindow):
         while x < sz.width:
             y = -dy
             while y < sz.height:
         while x < sz.width:
             y = -dy
             while y < sz.height:
-                dc.DrawBitmap(self.bg_bmp, (x, y))
+                dc.DrawBitmap(self.bg_bmp, x, y)
                 y = y + h
 
             x = x + w
                 y = y + h
 
             x = x + w
@@ -96,7 +97,6 @@ class TestWindow(wx.ScrolledWindow):
 
 
     def Draw(self, dc, rgn=None, vs=None):
 
 
     def Draw(self, dc, rgn=None, vs=None):
-        dc.BeginDrawing()
         dc.SetTextForeground("BLACK")
         dc.SetPen(wx.Pen("BLACK", 1, wx.SOLID))
         dc.SetFont(self.font)
         dc.SetTextForeground("BLACK")
         dc.SetPen(wx.Pen("BLACK", 1, wx.SOLID))
         dc.SetFont(self.font)
@@ -117,18 +117,18 @@ class TestWindow(wx.ScrolledWindow):
             stop = numColours
 
         for line in range(max(0,start), min(stop,numColours)):
             stop = numColours
 
         for line in range(max(0,start), min(stop,numColours)):
-            clr = colours[line]
+            clr = colours[line][0]
             y = (line+1) * self.lineHeight + 2
 
             y = (line+1) * self.lineHeight + 2
 
-            # Updated for 2.5 - now takes tuple for pos
-            dc.DrawText(clr, (self.cellWidth, y))
+            dc.DrawText(clr, self.cellWidth, y)
 
             brush = wx.Brush(clr, wx.SOLID)
             dc.SetBrush(brush)
 
             brush = wx.Brush(clr, wx.SOLID)
             dc.SetBrush(brush)
-            dc.DrawRectangle((12 * self.cellWidth, y),
-                             (6 * self.cellWidth, self.textHeight))
-
-        dc.EndDrawing()
+            dc.DrawRectangle(10 * self.cellWidth, y,
+                             6 * self.cellWidth, self.textHeight)
+            
+            dc.DrawText(str(tuple(colours[line][1:])),
+                        18 * self.cellWidth, y)
 
 
 # On wxGTK there needs to be a panel under wx.ScrolledWindows if they are
 
 
 # On wxGTK there needs to be a panel under wx.ScrolledWindows if they are
@@ -196,5 +196,5 @@ Trying to do otherwise will cause an exception to be raised.
 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:])