The VColorComboBox is a QComboBox widget that lets the user select a color.
Inherits: QComboBox
Class Attributes
Methods
Signals
The VColorComboBox is a QComboBox widget that lets the user select a color.
The VColorComboBox has a default palette of colors, called BASIC_PLT wich has twenty colors.
A custom palette can be set with set_palette
The color space, wich default is RGB, must be defined with the palette and can’t be changed later.
A new color can be appended or inserted into the palette with append_color and insert_color or can be removed with remove_color.
The palette can be sorted by name or by color.
With addMoreChoice the VColorComboBox can have a ‘More...’ item wich make the user be able to add a color of its choice.
Class Attributes
Define the color spaces available.
Currently, the color spaces supported are: ‘RGB’, ‘CMYK’, ‘HSV’ and ‘HSL’.
see set_palette
Define the sorting modes available.
Currently, the sorting modes implemented are: ‘alpha’, ‘red’, ‘green’ or ‘blue’
see set_palette
Methods
Add an item ‘More...’ at the end of the list of colors.
Arguments:
- add Boolean, if True, add the item ‘More...’, if False, remove it.
- call If True (default), a QColorDialog is called when this item is selected, otherwise a signal moreColorsRequested is emitted.
This property can be defined in the Qt Designer.
see hasMoreChoice
Add a new color to the end of the list.
Arguments:
- color A QColor() instance or a tuple(r, g, b[, a]).
- name The name of the color. If not provided and if namedColor is True, the name returned by QColor.name() will be used.
Returns the color of the icon’s border.
Type: QColor(r, g, b).
This is a pyqtProperty.
Returns True if the QColorDialog() is called when the ‘More ...’ item is clicked.
This is a pyqtProperty.
Returns the index of a color.
Argument:
- color A QColor() instance or a tuple(r, g, b[, a]).
Returns the current colors list.
The list is in the same order as in the combobox and the colors are tuples which contain the color’s name and the QColor() instance.
Example:
[('Red', QColor(255, 0, 0)), ('Green', QColor(0, 255, 0)), ...]
Type: list().
Returns the current color space.
Type: str().
Returns the current color as tuple(name, QColor(r, g, b)).
Type: tuple().
Returns the name of the current color.
Type: str().
Returns the height of the comboBox.
Type: int().
Returns the height of the icon.
Type: int().
Returns the size of the icon as tuple(width, height).
Type: tuple(int(), int()).
Returns the width of the icon.
Type: int().
Returns the sorting mode wich can be ‘provided’ if the order of the colors has been set with the palette or can be ‘alpha’, ‘red’, ‘green’ or ‘blue’ if the sorting mode has been set with set_sorting_mode.
Type: str().
Returns the size of the widget as tuple(width, height).
Type: int().
Returns the width of the widget.
Type: int().
Returns True if the color combobox has an item ‘More...’.
This is a pyqtProperty.
Type: boolean.
see addMoreChoice
Inserts a new color at the given index.
Arguments:
- idx The index.
- color A QColor instance or a tuple(r, g, b[, a]).
- name The name of the color, if not provided and if namedColor is True, the name returned by QColor.name will be used.
Inserts a new color at the right place.
If the sorting mode is ‘provided’, the new color will be appended to the palette, otherwise the color will be inserted in respect of the mode defined.
Arguments:
- color A QColor instance or a tuple(r, g, b[, a]).
- name The name of the color, if not provided and if namedColor is True, the name returned by QColor.name will be used.
see set_sorting_mode
Returns True if the name of the colors must be shown.
This is a pyqtProperty.
Type: boolean.
see setNamedColor
Returns the text ‘More ...’.
This is a pyqtProperty.
Type: str().
see setMoreText
Returns the palette as dictionary.
Type: dict().
see set_palette
Removes an item color from the comboBox.
Argument:
- item color Can be the item’s index or a QColor() instance or a tuple(r, g, b) or at least a str(‘#RRGGBB’)
Sets the color for the icon border.
This allows to enhance the contrast of the icon when the background of the comboBox is colored with a style sheet.
This property can be defined in the Qt Designer.
Argument:
- color Can be a QColor() instance or a tuple (r, g, b[, a]).
see borderIconColor
If argument is True, the QColorDialog is called when the user select the ‘More...’ item.
The new color selected in the dialog will be added to the palette in respect with the sorting mode.
If the property useSvgNaming is True, and if the new color is in the colors defined into the list of SVG color names, this name will be used, otherwise the name returned by QColor.name() is shown.
If argument is False, the signal moreColorsRequested will be emitted.
This property can be defined in the Qt Designer.
Argument:
- bool boolean.
Sets current the item ‘color’.
Argument:
- color Can be a QColor() instance, the index of the item or at least the name of the color.
Sets the text text to be used for the item ‘More...’.
By default, the text is ‘More...’, this method allows the possibility to translate the text.
This property can be defined into Qt Designer.
Argument:
- text str().
see moreText
If the argument is True, the name of the colors is visible, otherwise only the icons are shown.
This property can be defined into Qt Designer.
Argument:
- bool boolean
see isNamedColor
Sets the color’s palette.
The palette must be a dictionary with the color name as key and the value can be a QColor() instance or a tuple (r, g, b[, a]) or again a str(‘#RRGGBB’).
If the dictionary contents a key ‘SPACE’, a color space other than RGB may be defined. Color spaces supported: ‘RGB’, ‘CMYK’, ‘HSV’ and ‘HSL’.
With the key ‘ORDER’ the sorting order may be defined. The value must be the list of the names of the colors. Default sorting mode is alphabetical.
The keys ‘ORDER’ and ‘SPACE’, if exists, must be in upper case.
If no palette is defined, the default BASIC_PLT will be used. This palette contents these twenty colors:
BASIC_PLT = {'Red': (255, 0, 0), 'Orangered': (255, 69, 0),
'Crimson': (220, 20, 60), 'Dark red': (128, 0, 0),
'Green': (0, 255, 0), 'Limegreen': (50, 205, 50),
'Light green': (14, 255, 187), 'Dark green': (0, 128, 0),
'Blue': (0, 0, 255), 'Royal blue': (65, 105, 225),
'Indigo': (75, 0, 130), 'Dark blue': (0, 0, 128),
'Cyan': (0, 255, 255), 'Magenta': (255, 0, 255),
'Yellow': (255, 255, 0), 'Gray': (160, 160, 160),
'Light gray': (192, 192, 192), 'Dark gray': (128, 128, 128),
'White': (255, 255, 255), 'Black': (0, 0, 0),
'ORDER': ['Red', 'Orangered', 'Crimson', 'Dark red',
'Green', 'Light green', 'Limegreen', 'Dark green',
'Blue', 'Royal blue', 'Indigo', 'Dark blue',
'Cyan', 'Magenta', 'Yellow', 'Gray',
'Light gray', 'Dark gray', 'White', 'Black']}
Argument:
- palette dict().
Define the sorting mode.
Note: If the sorting order has been defined with the palette, changing the sorting mode has no effect.
Argument:
- mode str().
If the argument is True, when an unamed color is added to the palette, the name of the SVG standart will be used if the color exists in the standart.
This pyqtProperty can be defined into Qt Designer.
Argument:
- bool boolean.
see useSvgNaming
Returns True if the SVG naming standart is used for the name of the colors.
This is a pyqtProperty.
Type: boolean.
see setUseSvgNaming
Signals
This signal is sent whenever the current color in the combobox changes.
Type: name has type QString with Python v2.x and type str() with Python v3.x and QColor is an instance of QColor.