Class: QgsCompoundColorWidget

A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel, color swatches, and a color sampler.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsCompoundColorWidget

Base classes

QgsPanelWidget

Base class for any widget that can be shown as an inline panel.

QWidget

QObject

QPaintDevice

class qgis.gui.QgsCompoundColorWidget[source]

Bases: QgsPanelWidget

__init__(parent: QWidget | None = None, color: QColor | Qt.GlobalColor = QColor(), layout: QgsCompoundColorWidget.Layout = QgsCompoundColorWidget.LayoutDefault)

Constructor for QgsCompoundColorWidget

Parameters:
  • parent (Optional[QWidget] = None) – parent widget

  • color (Union[QColor, Qt.GlobalColor] = QColor()) – initial color for dialog

  • layout (QgsCompoundColorWidget.Layout = QgsCompoundColorWidget.LayoutDefault) – widget layout to use

class Layout

Bases: int

LayoutDefault = 0
LayoutVertical = 1
color(self) QColor[source]

Returns the current color for the dialog

Return type:

QColor

Returns:

dialog color

static createNewUserPalette(parent: QWidget | None) QgsUserColorScheme | None[source]

Triggers a user prompt for creating a new user color scheme.

The parent argument must be set to a valid parent widget for the dialog prompts.

Added in version 3.2.

Parameters:

parent (Optional[QWidget])

Return type:

Optional[QgsUserColorScheme]

signal currentColorChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

static importUserPaletteFromFile(parent: QWidget | None) QgsUserColorScheme | None[source]

Triggers a user prompt for importing a new color scheme from an existing GPL file.

The parent argument must be set to a valid parent widget for the dialog prompts.

Added in version 3.2.

Parameters:

parent (Optional[QWidget])

Return type:

Optional[QgsUserColorScheme]

static removeUserPalette(scheme: QgsUserColorScheme | None, parent: QWidget | None) bool[source]

Triggers a user prompt for removing an existing user color scheme.

The parent argument must be set to a valid parent widget for the dialog prompts.

Added in version 3.2.

Parameters:
Return type:

bool

setAllowOpacity(self, allowOpacity: bool)[source]

Sets whether opacity modification (transparency) is permitted for the color dialog. Defaults to True.

Parameters:

allowOpacity (bool) – set to False to disable opacity modification

setColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the current color for the dialog

Parameters:

color (Union[QColor, Qt.GlobalColor]) – desired color

setColorModelEditable(self, colorModelEditable: bool)[source]

Sets whether color model is editable or not

Parameters:

colorModelEditable (bool) – set to False to disable color model modification Defaults to True.

Added in version 3.40.

setDiscarded(self, discarded: bool)[source]

Sets whether the widget’s color has been “discarded” and the selected color should not be stored in the recent color list.

Parameters:

discarded (bool) – set to True to avoid adding color to recent color list on widget destruction.

setPreviousColor(self, color: QColor | Qt.GlobalColor)[source]

Sets the color to show in an optional “previous color” section

Parameters:

color (Union[QColor, Qt.GlobalColor]) – previous color