Class: QgsColorSchemeList¶
An editable list of color swatches, taken from an associated
QgsColorScheme
.
See also
Class Hierarchy¶
Base classes¶
Methods
Adds a color to the list |
|
Copies colors from the list to the clipboard |
|
Export colors to a GPL palette file from the list |
|
Import colors from a GPL palette file to the list |
|
Returns whether the color scheme list has been modified |
|
Pastes colors from clipboard to the list |
|
Removes any selected colors from the list |
|
Saves the current colors shown in the list back to a color scheme, if supported by the color scheme. |
|
Returns the scheme currently selected in the list. |
|
Sets the color scheme to show in the list |
|
Displays a file picker dialog allowing users to export colors from the list into a file. |
|
Displays a file picker dialog allowing users to import colors into the list from a file. |
Signals
Emitted when a color is selected from the list |
- 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 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
True
to allow duplicate colors to be added, ie colors which already exist in the list
- signal colorSelected(color: QColor)[source]¶
Emitted when a color is selected from the list
- Parameters:
color (QColor) – color selected
- 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:
True
if 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]) –
QgsColorScheme
for 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