.. include:: headings.inc .. _ColourPickerCtrl: ========================================================================================================================================== |phoenix_title| **ColourPickerCtrl** ========================================================================================================================================== This control allows the user to select a colour. The generic implementation is a button which brings up a :ref:`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). .. _ColourPickerCtrl-styles: |styles| Window Styles ================================ This class supports the following styles: - ``CLRP_DEFAULT_STYLE``: The default style: 0. - ``CLRP_USE_TEXTCTRL``: Creates a text control to the left of the picker button which is completely managed by the :ref:`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 :ref:`PickerBase` to modify the text control. - ``CLRP_SHOW_LABEL``: Shows the colour in ``HTML`` form (``AABBCC``) as colour button label (instead of no label at all). .. _ColourPickerCtrl-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`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). .. seealso:: :ref:`ColourDialog`, :ref:`ColourPickerEvent` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **ColourPickerCtrl** .. raw:: html

Inheritance diagram of ColourPickerCtrl

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/colourpickerctrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/colourpickerctrl.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/colourpickerctrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~ColourPickerCtrl.__init__` :meth:`~ColourPickerCtrl.Create` Creates a colour picker with the given arguments. :meth:`~ColourPickerCtrl.GetColour` Returns the currently selected colour. :meth:`~ColourPickerCtrl.SetColour` Sets the currently selected colour. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~ColourPickerCtrl.Colour` See :meth:`~ColourPickerCtrl.GetColour` and :meth:`~ColourPickerCtrl.SetColour` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: ColourPickerCtrl(PickerBase) This control allows the user to select a colour. **Possible constructors**:: ColourPickerCtrl() ColourPickerCtrl(parent, id=ID_ANY, colour=BLACK, pos=DefaultPosition, size=DefaultSize, style=CLRP_DEFAULT_STYLE, validator=DefaultValidator, name=ColourPickerCtrlNameStr) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__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 :meth:`Create` with all the parameters. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `colour`: :type `colour`: Colour :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `validator`: :type `validator`: Validator :param `name`: :type `name`: string **~~~** .. method:: 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. :param `parent`: Parent window, must not be not ``None``. :type `parent`: Window :param `id`: The identifier for the control. :type `id`: int :param `colour`: The initial colour shown in the control. :type `colour`: Colour :param `pos`: Initial position. :type `pos`: Point :param `size`: Initial size. :type `size`: Size :param `style`: The window style, see ``CRLP_`` flags. :type `style`: long :param `validator`: Validator which can be used for additional date checks. :type `validator`: Validator :param `name`: Control name. :type `name`: string :rtype: `bool` :returns: ``True`` if the control was successfully created or ``False`` if creation failed. .. method:: GetColour(self) Returns the currently selected colour. :rtype: :ref:`Colour` .. method:: SetColour(self, *args, **kw) Sets the currently selected colour. See :meth:`Colour.Set` . |overload| **Overloaded Implementations**: **~~~** **SetColour** `(self, col)` :param `col`: :type `col`: Colour **~~~** **SetColour** `(self, colname)` :param `colname`: :type `colname`: string **~~~** .. attribute:: Colour See :meth:`~ColourPickerCtrl.GetColour` and :meth:`~ColourPickerCtrl.SetColour`