Class: QgsColorSchemeList¶
An editable list of color swatches, taken from an associated
QgsColorScheme.
See also
Class Hierarchy¶
Base classes¶
- 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) –
QgsColorSchemefor colors to show in the listcontext (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
Trueto 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.
- exportColorsToGpl(self, file: QFile) bool[source]¶
Export colors to a GPL palette file from the list
- Parameters:
file (QFile) – destination file
See also
- 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
See also
- Return type:
bool
- isDirty(self) bool[source]¶
Returns whether the color scheme list has been modified
- Return type:
bool
- Returns:
Trueif colors have been modified
- 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
- 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]) –
QgsColorSchemefor colors to show in the listcontext (Optional[str] = '') – context string provided to color scheme
baseColor (Union[QColor, Qt.GlobalColor] = QColor()) – base color for color scheme
See also
- showExportColorsDialog(self)[source]¶
Displays a file picker dialog allowing users to export colors from the list into a file.
See also