Class: QgsColorSwatchGridAction

class qgis.gui.QgsColorSwatchGridAction

Bases: PyQt5.QtWidgets.QWidgetAction

A color swatch grid which can be embedded into a menu.

New in version 2.5.

QgsColorSwatchGridAction(scheme: QgsColorScheme, menu: QMenu = None, context: str = ‘’, parent: QWidget = None) Construct a new color swatch grid action.

Parameters
baseColor(self) QColor

Gets the base color for the color grid

Return type

QColor

Returns

base color which is passed to scheme for color generation

See also

setBaseColor()

childEvent(self, QChildEvent)
colorChanged

Emitted when a color has been selected from the widget

Parameters

color (Union[QColor) – selected color [signal]

connectNotify(self, QMetaMethod)
context(self) str

Gets the current context for the color grid

Return type

str

Returns

context string which is passed to scheme for color generation

See also

setContext()

createWidget(self, QWidget) QWidget
createdWidgets(self) List[QWidget]
customEvent(self, QEvent)
deleteWidget(self, QWidget)
disconnectNotify(self, QMetaMethod)
dismissOnColorSelection(self) bool

Returns whether the parent menu will be dismissed after a color is selected from the action’s color widget.

New in version 2.14.

Return type

bool

event(self, QEvent) bool
eventFilter(self, QObject, QEvent) bool
isSignalConnected(self, QMetaMethod) bool
receivers(self, PYQT_SIGNAL) int
refreshColors(self)

Reload colors from scheme and redraws the widget

sender(self) QObject
senderSignalIndex(self) int
setBaseColor(self, baseColor: Union[QColor, Qt.GlobalColor, QGradient])

Sets the base color for the color grid

Parameters

baseColor (Union[QColor) – base color to pass to scheme for color generation

See also

baseColor()

setContext(self, context: str)

Sets the current context for the color grid

Parameters

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

See also

context()

setDismissOnColorSelection(self, dismiss: bool)

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 to False, the colorChanged signal will be emitted but the menu will stay open.

New in version 2.14.

timerEvent(self, QTimerEvent)