]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/wxPython/lib/colourselect.py
Added more contribs from Lorne White, and updated some of the existing ones.
[wxWidgets.git] / wxPython / wxPython / lib / colourselect.py
index 93774eb9a6f7995dd61662d397d873a5fef8e7d8..9f0d7a9506122b92c2d4a44cec2d9f72e1603497 100644 (file)
@@ -17,30 +17,37 @@ from wxPython.wx import *
 # GetColour method to get the selected colour
 
 class ColourSelect(wxButton):
-    def __init__(self, parent, id, bcolour=(0, 0, 0), pos=wxDefaultPosition, size=wxDefaultSize):
-        wxButton.__init__(self, parent, id, "", pos=pos, size=size)
-        EVT_BUTTON(parent, self.GetId(), self.OnClick)
-        self.SetForegroundColour(wxWHITE)
-        self.SetColour(bcolour)
+    def __init__(self, parent, position = wxPoint(20, 20), bcolour = [0, 0, 0], size = wxSize(20, 20)):
+        self.win = parent
 
+        mID = NewId()
+        self.b = b = wxButton(parent, mID, "", position, size)
+        EVT_BUTTON(parent, mID, self.OnClick)
 
-    def SetColour(self, bcolour):
         self.set_colour_val = set_colour = wxColor(bcolour[0], bcolour[1], bcolour[2])
-        self.SetBackgroundColour(set_colour)
+        b.SetBackgroundColour(set_colour)
+        b.SetForegroundColour(wxWHITE)
         self.set_colour = bcolour
 
+    def SetColour(self, bcolour):
+        self.b.SetBackgroundColour(bcolour)
 
     def GetColour(self):
         return self.set_colour
 
-
     def OnClick(self, event):
         data = wxColourData()
         data.SetChooseFull(true)
         data.SetColour(self.set_colour_val)
-        dlg = wxColourDialog(self.GetParent(), data)
+        dlg = wxColourDialog(self.win, data)
         if dlg.ShowModal() == wxID_OK:
             data = dlg.GetColourData()
-            self.SetColour(data.GetColour().Get())
+            self.set_colour = set = data.GetColour().Get()
+            self.set_colour_val = bcolour = wxColour(set[0],set[1],set[2])
+            self.b.SetBackgroundColour(bcolour)
         dlg.Destroy()
 
+
+
+
+