Class: QgsColorSchemeList

An editable list of color swatches, taken from an associated QgsColorScheme.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorSchemeList

Base classes

QTreeView

QAbstractItemView

QAbstractScrollArea

QFrame

QWidget

QObject

QPaintDevice

class qgis.gui.QgsColorSchemeList[source]

Bases: QTreeView

__init__(parent: QWidget | None = None, scheme: QgsColorScheme | None = None, context: str | None = '', baseColor: QColor | Qt.GlobalColor = QColor())

Construct a new color swatch grid.

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

  • scheme (Optional[QgsColorScheme] = None) – QgsColorScheme for colors to show in the list

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

  • baseColor (Union[QColor, Qt.GlobalColor] = QColor()) – base color for color scheme

addColor(self, color: QColor | Qt.GlobalColor, label: str | None = '', allowDuplicate: bool = False)[source]

Adds a color to the list

Parameters:
  • color (Union[QColor, Qt.GlobalColor]) – color to add

  • label (Optional[str] = '') – optional label for color

  • allowDuplicate (bool = False) – set to True to allow duplicate colors to be added, ie colors which already exist in the list

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

copyColors(self)[source]

Copies colors from the list to the clipboard

See also

pasteColors()

exportColorsToGpl(self, file: QFile) bool[source]

Export colors to a GPL palette file from the list

Parameters:

file (QFile) – destination file

Return type:

bool

importColorsFromGpl(self, file: QFile) bool[source]

Import colors from a GPL palette file to the list

Parameters:

file (QFile) – file to import

Return type:

bool

isDirty(self) bool[source]

Returns whether the color scheme list has been modified

Return type:

bool

Returns:

True if colors have been modified

pasteColors(self)[source]

Pastes colors from clipboard to the list

See also

copyColors()

removeSelection(self)[source]

Removes any selected colors from the list

saveColorsToScheme(self) bool[source]

Saves the current colors shown in the list back to a color scheme, if supported by the color scheme.

Note

this method is only effective if the color scheme is editable

Return type:

bool

scheme(self) QgsColorScheme | None[source]

Returns the scheme currently selected in the list.

See also

setScheme()

Return type:

Optional[QgsColorScheme]

setScheme(self, scheme: QgsColorScheme | None, context: str | None = '', baseColor: QColor | Qt.GlobalColor = QColor())[source]

Sets the color scheme to show in the list

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

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

  • baseColor (Union[QColor, Qt.GlobalColor] = QColor()) – base color for color scheme

See also

scheme()

showExportColorsDialog(self)[source]

Displays a file picker dialog allowing users to export colors from the list into a file.

showImportColorsDialog(self)[source]

Displays a file picker dialog allowing users to import colors into the list from a file.