]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/colourselect.py
17b86199f7dfd336053e14cfb78db0d12e6da876
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
20 def __init__(self
, parent
, position
= wxPoint(20, 20), bcolour
= [0, 0, 0], size
= wxSize(20, 20)):
26 self
.b
= b
= wxButton(parent
, mID
, "", position
, size
)
27 EVT_BUTTON(parent
, mID
, self
.OnClick
)
29 self
.set_colour_val
= set_colour
= wxColor(bcolour
[0], bcolour
[1], bcolour
[2])
30 b
.SetBackgroundColour(set_colour
)
31 b
.SetForegroundColour(wxWHITE
)
32 self
.set_colour
= bcolour
34 def SetColour(self
, bcolour
):
35 self
.b
.SetBackgroundColour(bcolour
)
38 return self
.set_colour
40 def OnClick(self
, event
):
42 data
.SetChooseFull(true
)
43 data
.SetColour(self
.set_colour_val
)
44 dlg
= wxColourDialog(self
.win
, data
)
45 if dlg
.ShowModal() == wxID_OK
:
46 data
= dlg
.GetColourData()
47 self
.set_colour
= set = data
.GetColour().Get()
48 self
.set_colour_val
= bcolour
= wxColour(set[0],set[1],set[2])
49 self
.b
.SetBackgroundColour(bcolour
)