Subgroup: Color

Class: QgsColorSwatchGrid

class qgis.gui.QgsColorSwatchGrid(scheme: QgsColorScheme, context: str = '', parent: QWidget = None)

Bases: PyQt5.QtWidgets.QWidget

Construct a new color swatch grid.

Parameters:
  • scheme – QgsColorScheme for colors to show in grid
  • context – context string provided to color scheme
  • parent – parent widget

A grid of color swatches, which allows for user selection. Colors are taken from an associated QgsColorScheme.

See also

QgsColorGridAction

New in version 2.5: Methods

actionEvent
baseColor Get the base color for the widget
changeEvent
childEvent
closeEvent
colors Gets the list of colors shown in the grid
connectNotify
context Get the current context for the grid
contextMenuEvent
create
customEvent
destroy
disconnectNotify
dragEnterEvent
dragLeaveEvent
dragMoveEvent
dropEvent
enterEvent
event
focusInEvent
focusNextChild
focusNextPrevChild
focusOutEvent
focusPreviousChild
hideEvent
initPainter
inputMethodEvent
isSignalConnected
keyPressEvent
keyReleaseEvent
leaveEvent
metric
minimumSizeHint
mouseDoubleClickEvent
mouseMoveEvent
mousePressEvent
mouseReleaseEvent
moveEvent
nativeEvent
paintEvent
receivers
refreshColors Reload colors from scheme and redraws the widget
resizeEvent
sender
senderSignalIndex
setBaseColor Sets the base color for the widget
setContext Sets the current context for the grid
sharedPainter
showEvent
sizeHint
tabletEvent
timerEvent
updateMicroFocus
wheelEvent

Signals

colorChanged Emitted when a color has been selected from the widget
hovered Emitted when mouse hovers over widget [signal]

Attributes

actionEvent()
baseColor(self) → QColor

Get the base color for the widget

Returns:base color which is passed to scheme for color generation

See also

setBaseColor()

changeEvent()
childEvent()
closeEvent()
colorChanged

Emitted when a color has been selected from the widget

Parameters:color – selected color [signal]
colors(self) → object

Gets the list of colors shown in the grid

Returns:list of colors currently shown in the grid
connectNotify()
context(self) → str

Get the current context for the grid

Returns:context string which is passed to scheme for color generation

See also

setContext()

contextMenuEvent()
create()
customEvent()
destroy()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
enterEvent()
event()
focusInEvent(self, event: QFocusEvent)
focusNextChild()
focusNextPrevChild()
focusOutEvent(self, event: QFocusEvent)
focusPreviousChild()
hideEvent()
hovered

Emitted when mouse hovers over widget [signal]

initPainter()
inputMethodEvent()
isSignalConnected()
keyPressEvent(self, event: QKeyEvent)
keyReleaseEvent()
leaveEvent()
metric()
minimumSizeHint(self) → QSize
mouseDoubleClickEvent()
mouseMoveEvent(self, event: QMouseEvent)
mousePressEvent(self, event: QMouseEvent)
mouseReleaseEvent(self, event: QMouseEvent)
moveEvent()
nativeEvent()
paintEvent(self, event: QPaintEvent)
receivers()
refreshColors(self)

Reload colors from scheme and redraws the widget

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

Sets the base color for the widget

Parameters:baseColor – base color to pass to scheme for color generation

See also

baseColor()

setContext(self, context: str)

Sets the current context for the grid

Parameters:context – string which is passed to scheme for color generation

See also

context()

sharedPainter()
showEvent()
sizeHint(self) → QSize
tabletEvent()
timerEvent()
updateMicroFocus()
wheelEvent()