Class: QgsColorSwatchGridAction¶
A color swatch grid which can be embedded into a menu.
See also
Class Hierarchy¶
Base classes¶
Methods
Gets the base color for the color grid |
|
Gets the current context for the color grid |
|
Returns whether the parent menu will be dismissed after a color is selected from the action's color widget. |
|
Reload colors from scheme and redraws the widget |
|
Sets the base color for the color grid |
|
Sets the current context for the color grid |
|
Sets whether the parent menu should be dismissed and closed when a color is selected from the action's color widget. |
Signals
Emitted when a color has been selected from the widget |
- class qgis.gui.QgsColorSwatchGridAction[source]¶
Bases:
QWidgetAction
- __init__(scheme: QgsColorScheme | None, menu: QMenu | None = None, context: str | None = '', parent: QWidget | None = None)
Construct a new color swatch grid action.
- Parameters:
scheme (Optional[QgsColorScheme]) –
QgsColorScheme
for colors to show in gridmenu (Optional[QMenu] = None) – parent menu
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 color grid
- Return type:
QColor
- Returns:
base color which is passed to scheme for color generation
See also
- signal colorChanged(color: QColor)[source]¶
Emitted when a color has been selected from the widget
- Parameters:
color (QColor) – selected color
- context(self) str [source]¶
Gets the current context for the color grid
- Return type:
str
- Returns:
context string which is passed to scheme for color generation
See also
- dismissOnColorSelection(self) bool [source]¶
Returns whether the parent menu will be dismissed after a color is selected from the action’s color widget.
See also
- Return type:
bool
- setBaseColor(self, baseColor: QColor | Qt.GlobalColor)[source]¶
Sets the base color for the color grid
- Parameters:
baseColor (Union[QColor, Qt.GlobalColor]) – base color to pass to scheme for color generation
See also
- setContext(self, context: str | None)[source]¶
Sets the current context for the color grid
- Parameters:
context (Optional[str]) – string which is passed to scheme for color generation
See also
- setDismissOnColorSelection(self, dismiss: bool)[source]¶
Sets whether the parent menu should be dismissed and closed when a color is selected from the action’s color widget.
- Parameters:
dismiss (bool) – set to
True
(default) to immediately close the menu when a color is selected from the widget. If set toFalse
, the colorChanged signal will be emitted but the menu will stay open.
See also