Class: QgsColorSwatchGrid

A grid of color swatches, which allows for user selection.

Colors are taken from an associated QgsColorScheme.

See also

QgsColorGridAction

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorSwatchGrid

Base classes

QWidget

QObject

QPaintDevice

class qgis.gui.QgsColorSwatchGrid[source]

Bases: QWidget

__init__(scheme: QgsColorScheme | None, context: str | None = '', parent: QWidget | None = None)

Construct a new color swatch grid.

Parameters:
  • scheme (Optional[QgsColorScheme]) – QgsColorScheme for colors to show in grid

  • context (Optional[str] = '') – context string provided to color scheme

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

baseColor(self) QColor[source]

Gets the base color for the widget

Return type:

QColor

Returns:

base color which is passed to scheme for color generation

See also

setBaseColor()

signal colorChanged[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.

colors(self) List[Tuple[QColor, str]] | None[source]

Gets the list of colors shown in the grid

Return type:

Optional[List[Tuple[QColor, str]]]

Returns:

list of colors currently shown in the grid

context(self) str[source]

Gets the current context for the grid

Return type:

str

Returns:

context string which is passed to scheme for color generation

See also

setContext()

signal hovered[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.

refreshColors(self)[source]

Reload colors from scheme and redraws the widget

setBaseColor(self, baseColor: QColor | Qt.GlobalColor)[source]

Sets the base color for the widget

Parameters:

baseColor (Union[QColor, Qt.GlobalColor]) – base color to pass to scheme for color generation

See also

baseColor()

setContext(self, context: str | None)[source]

Sets the current context for the grid

Parameters:

context (Optional[str]) – string which is passed to scheme for color generation

See also

context()