This control allows the user to select a colour.
The generic implementation is a button which brings up a wx.ColourDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the colour-chooser dialog. It is only available if USE_COLOURPICKERCTRL
is set to 1 (the default).
^^
This class supports the following styles:
wx.CLRP_DEFAULT_STYLE
: The default style: 0.
wx.CLRP_USE_TEXTCTRL
: Creates a text control to the left of the picker button which is completely managed by the wx.ColourPickerCtrl and which can be used by the user to specify a colour (see SetColour). The text control is automatically synchronized with button’s value. Use functions defined in wx.PickerBase to modify the text control.
wx.CLRP_SHOW_LABEL
: Shows the colour in HTML form (AABBCC
) as colour button label (instead of no label at all).
wx.CLRP_SHOW_ALPHA
: Allows selecting opacity in the colour-chooser (effective under wxGTK and wxOSX). ^^
^^
Handlers bound for the following event types will receive a wx.ColourPickerEvent parameter.
EVT_COLOURPICKER_CHANGED: The user changed the colour selected in the control either using the button or using text control (see CLRP_USE_TEXTCTRL
; note that in this case the event is fired only if the user’s input is valid, i.e. recognizable). When using a popup dialog for changing the colour, this event is sent only when the changes in the dialog are accepted by the user, unlike EVT_COLOURPICKER_CURRENT_CHANGED
.
EVT_COLOURPICKER_CURRENT_CHANGED: The user changed the currently selected colour in the dialog associated with the control. This event is sent immediately when the selection changes and you must also handle EVT_COLOUR_CANCELLED
to revert to the previously selected colour if the selection ends up not being accepted. This event is new since wxWidgets 3.1.3 and currently is only implemented in wxMSW.
EVT_COLOURPICKER_DIALOG_CANCELLED: The user cancelled the colour dialog associated with the control, i.e. closed it without accepting the selection. This event is new since wxWidgets 3.1.3 and currently is only implemented in wxMSW. ^^
Creates a colour picker with the given arguments. |
|
Returns the currently selected colour. |
|
Sets the currently selected colour. |
wx.
ColourPickerCtrl
(PickerBase)¶Possible constructors:
ColourPickerCtrl()
ColourPickerCtrl(parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition,
size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator,
name=ColourPickerCtrlNameStr)
This control allows the user to select a colour.
__init__
(self, *args, **kw)¶__init__ (self)
__init__ (self, parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition, size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator, name=ColourPickerCtrlNameStr)
Initializes the object and calls Create
with all the parameters.
parent (wx.Window) –
id (wx.WindowID) –
colour (wx.Colour) –
pos (wx.Point) –
size (wx.Size) –
style (long) –
validator (wx.Validator) –
name (string) –
Create
(self, parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition, size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator, name=ColourPickerCtrlNameStr)¶Creates a colour picker with the given arguments.
parent (wx.Window) – Parent window, must not be not None
.
id (wx.WindowID) – The identifier for the control.
colour (wx.Colour) – The initial colour shown in the control.
pos (wx.Point) – Initial position.
size (wx.Size) – Initial size.
style (long) – The window style, see CRLP_
flags.
validator (wx.Validator) – Validator which can be used for additional data checks.
name (string) – Control name.
bool
True
if the control was successfully created or False
if creation failed.
GetClassDefaultAttributes
(variant=WINDOW_VARIANT_NORMAL)¶variant (WindowVariant) –
SetColour
(self, *args, **kw)¶Sets the currently selected colour.
See wx.Colour.Set
.
SetColour (self, col)
col (wx.Colour) –
SetColour (self, colname)
colname (string) –