]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/analogclock/lib_setup/colourselect.py
1 # AnalogClock's colour selector for setup dialog
2 # E. A. Tacao <e.a.tacao |at| estadao.com.br>
3 # http://j.domaindlx.com/elements28/wxpython/
4 # 15 Fev 2006, 22:00 GMT-03:00
5 # Distributed under the wxWidgets license.
8 from wx
.lib
.newevent
import NewEvent
9 from wx
.lib
.buttons
import GenBitmapButton
11 #----------------------------------------------------------------------------
13 (ColourSelectEvent
, EVT_COLOURSELECT
) = NewEvent()
15 #----------------------------------------------------------------------------
17 class ColourSelect(GenBitmapButton
):
18 def __init__(self
, parent
, size
=(21, 21), value
=wx
.BLACK
):
19 w
, h
= size
[0] - 5, size
[1] - 5
20 GenBitmapButton
.__init
__(self
, parent
, wx
.ID_ANY
, wx
.EmptyBitmap(w
, h
),
27 self
.parent
.Bind(wx
.EVT_BUTTON
, self
.OnClick
, self
)
30 def _makeBitmap(self
):
31 bdr
= 8; w
, h
= self
.GetSize()
32 bmp
= wx
.EmptyBitmap(w
- bdr
, h
- bdr
)
36 dc
.SetBackground(wx
.Brush(self
.value
, wx
.SOLID
))
38 dc
.SelectObject(wx
.NullBitmap
)
40 self
.SetBitmapLabel(bmp
)
48 def SetValue(self
, value
):
53 def OnClick(self
, event
):
54 win
= wx
.GetTopLevelParent(self
)
56 data
= wx
.ColourData()
57 data
.SetChooseFull(True)
58 data
.SetColour(self
.value
)
59 [data
.SetCustomColour(colour_index
, win
.customcolours
[colour_index
])
60 for colour_index
in range(0, 16)]
62 dlg
= wx
.ColourDialog(win
, data
)
63 dlg
.SetTitle("Select Colour")
64 changed
= dlg
.ShowModal() == wx
.ID_OK
67 data
= dlg
.GetColourData()
68 self
.SetValue(data
.GetColour())
69 win
.customcolours
= [data
.GetCustomColour(colour_index
) \
70 for colour_index
in range(0, 16)]
74 nevt
= ColourSelectEvent(id=self
.GetId(), obj
=self
, val
=self
.value
)
75 wx
.PostEvent(self
.parent
, nevt
)