]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/colourselect.py
93774eb9a6f7995dd61662d397d873a5fef8e7d8
2 #----------------------------------------------------------------------------
3 # Name: ColourSelect.py
4 # Purpose: Colour Box Selection Control
6 # Author: Lorne White, Lorne.White@telusplanet.net
8 # Created: Feb 25, 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
19 class ColourSelect(wxButton
):
20 def __init__(self
, parent
, id, bcolour
=(0, 0, 0), pos
=wxDefaultPosition
, size
=wxDefaultSize
):
21 wxButton
.__init
__(self
, parent
, id, "", pos
=pos
, size
=size
)
22 EVT_BUTTON(parent
, self
.GetId(), self
.OnClick
)
23 self
.SetForegroundColour(wxWHITE
)
24 self
.SetColour(bcolour
)
27 def SetColour(self
, bcolour
):
28 self
.set_colour_val
= set_colour
= wxColor(bcolour
[0], bcolour
[1], bcolour
[2])
29 self
.SetBackgroundColour(set_colour
)
30 self
.set_colour
= bcolour
34 return self
.set_colour
37 def OnClick(self
, event
):
39 data
.SetChooseFull(true
)
40 data
.SetColour(self
.set_colour_val
)
41 dlg
= wxColourDialog(self
.GetParent(), data
)
42 if dlg
.ShowModal() == wxID_OK
:
43 data
= dlg
.GetColourData()
44 self
.SetColour(data
.GetColour().Get())