]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/colourselect.py
590cf64e76399e3545977f2194266008705e855c
2 #----------------------------------------------------------------------------
3 # Name: ColourSelect.py
4 # Purpose: Colour Box Selection Control
6 # Author: Lorne White, Lorne.White@telusplanet.net
8 # Created: Sept 4, 2001
9 # Licence: wxWindows license
10 #----------------------------------------------------------------------------
12 from wxPython
.wx
import *
14 # creates a colour wxButton with selectable color
15 # button click provides a colour selection box
16 # button colour will change to new colour
17 # GetColour method to get the selected colour
20 # call back to function if changes made
22 class ColourSelect(wxButton
):
23 def __init__(self
, parent
, ID
, bcolour
=[0, 0, 0], pos
=wxPoint(20, 20), size
=wxSize(20, 20), style
=0, callback
=None):
24 wxButton
.__init
__(self
, parent
, ID
, "", pos
, size
, style
)
26 self
.callback
= callback
27 EVT_BUTTON(self
, ID
, self
.OnClick
)
28 self
.SetColourValue(bcolour
)
31 if hasattr(self
, "set_colour_val"):
32 del self
.set_colour_val
34 def SetColour(self
, bcolour
):
35 self
.SetBackgroundColour(bcolour
)
37 def SetColourValue(self
, bcolour
):
38 self
.set_colour_val
= wxColour(bcolour
[0], bcolour
[1], bcolour
[2])
39 self
.set_colour
= bcolour
41 self
.SetBackgroundColour(self
.set_colour_val
)
42 self
.SetForegroundColour(wxWHITE
)
44 def SetValue(self
, bcolour
):
45 self
.SetColourValue(bcolour
)
48 return self
.set_colour
51 if self
.callback
!= None:
54 def OnClick(self
, event
):
56 data
.SetChooseFull(true
)
57 data
.SetColour(self
.set_colour_val
)
58 dlg
= wxColourDialog(self
.win
, data
)
59 if dlg
.ShowModal() == wxID_OK
:
60 data
= dlg
.GetColourData()
61 self
.set_colour
= set = data
.GetColour().Get()
62 self
.set_colour_val
= bcolour
= wxColour(set[0],set[1],set[2])
63 self
.SetBackgroundColour(bcolour
)