]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wxPython/lib/colourselect.py
9759e9ac79afd0ac1a80b7bfacf24f703843505f
1 #----------------------------------------------------------------------------
2 # Name: ColourSelect.py
3 # Purpose: Colour Box Selection Control
5 # Author: Lorne White, Lorne.White@telusplanet.net
7 # Created: Sept 4, 2001
8 # Licence: wxWindows license
9 #----------------------------------------------------------------------------
11 from wxPython
.wx
import *
13 # creates a colour wxButton with selectable color
14 # button click provides a colour selection box
15 # button colour will change to new colour
16 # GetColour method to get the selected colour
19 # call back to function if changes made
21 class ColourSelect(wxButton
):
22 def __init__(self
, parent
, ID
, bcolour
=[0, 0, 0], pos
=wxPoint(20, 20), size
=wxSize(20, 20), style
=0, callback
=None):
23 wxButton
.__init
__(self
, parent
, ID
, "", pos
, size
, style
)
25 self
.callback
= callback
26 EVT_BUTTON(self
, ID
, self
.OnClick
)
27 self
.SetColourValue(bcolour
)
29 def SetColour(self
, bcolour
):
30 self
.SetBackgroundColour(bcolour
)
32 def SetColourValue(self
, bcolour
):
33 self
.set_colour
= bcolour
34 self
.SetBackgroundColour(self
.Get_wxColour())
35 self
.SetForegroundColour(wxWHITE
)
37 def SetValue(self
, bcolour
):
38 self
.SetColourValue(bcolour
)
41 return self
.set_colour
43 def Get_wxColour(self
):
44 return wxColour(self
.set_colour
[0], self
.set_colour
[1], self
.set_colour
[2])
47 if self
.callback
!= None:
50 def OnClick(self
, event
):
52 data
.SetChooseFull(true
)
53 data
.SetColour(self
.Get_wxColour())
54 dlg
= wxColourDialog(self
.win
, data
)
55 if dlg
.ShowModal() == wxID_OK
:
56 data
= dlg
.GetColourData()
57 self
.set_colour
= set = data
.GetColour().Get()
58 self
.SetBackgroundColour(self
.Get_wxColour())