]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wx/lib/colourselect.py
Fix "warning: operation on 'y' may be undefined".
[wxWidgets.git] / wxPython / wx / lib / colourselect.py
index 689e467e679198a5c43658baefa1614ba6f20e8a..1183fc4222a66bad5e838b288f46d2870ad8b3e6 100644 (file)
 # o Updated for 2.5 compatability.
 #
 
 # o Updated for 2.5 compatability.
 #
 
+"""
+Provides a `ColourSelect` button that, when clicked, will display a
+colour selection dialog.  The selected colour is displayed on the
+button itself.
+"""
+
 #----------------------------------------------------------------------------
 
 import  wx
 #----------------------------------------------------------------------------
 
 import  wx
@@ -104,8 +110,13 @@ class ColourSelect(wx.BitmapButton):
 
 
     def MakeBitmap(self):
 
 
     def MakeBitmap(self):
-        bdr = 10
+        bdr = 8
         width, height = self.GetSize()
         width, height = self.GetSize()
+
+        # yes, this is weird, but it appears to work around a bug in wxMac
+        if "wxMac" in wx.PlatformInfo and width == height:
+            height -= 1
+            
         bmp = wx.EmptyBitmap(width-bdr, height-bdr)
         dc = wx.MemoryDC()
         dc.SelectObject(bmp)
         bmp = wx.EmptyBitmap(width-bdr, height-bdr)
         dc = wx.MemoryDC()
         dc.SelectObject(bmp)
@@ -133,7 +144,8 @@ class ColourSelect(wx.BitmapButton):
         self.SetBitmapDisabled(bmp)
         self.SetBitmapFocus(bmp)
         self.SetBitmapSelected(bmp)
         self.SetBitmapDisabled(bmp)
         self.SetBitmapFocus(bmp)
         self.SetBitmapSelected(bmp)
-
+        self.Refresh()
+        
 
     def OnChange(self):
         wx.PostEvent(self, ColourSelectEvent(self.GetId(), self.GetValue()))
 
     def OnChange(self):
         wx.PostEvent(self, ColourSelectEvent(self.GetId(), self.GetValue()))
@@ -150,7 +162,6 @@ class ColourSelect(wx.BitmapButton):
         if changed:
             data = dlg.GetColourData()
             self.SetColour(data.GetColour())
         if changed:
             data = dlg.GetColourData()
             self.SetColour(data.GetColour())
-
         dlg.Destroy()
 
         # moved after dlg.Destroy, since who knows what the callback will do...
         dlg.Destroy()
 
         # moved after dlg.Destroy, since who knows what the callback will do...