Class: QgsColorRampWidget

class qgis.gui.QgsColorRampWidget(parent: QWidget = None, component: QgsColorWidget.ColorComponent = QgsColorWidget.Red, orientation: QgsColorRampWidget.Orientation = QgsColorRampWidget.Horizontal)

Bases: QgsColorWidget

Construct a new color ramp widget.

Parameters
  • parent – parent QWidget for the widget

  • component – color component which varies along the ramp

  • orientation – orientation for widget

A color ramp widget. This widget consists of an interactive box filled with a color which varies along its length by a single color component (e.g., varying saturation from 0 to 100%).

Methods

actionEvent

alterColor

Alters a color by modifying the value of a specific color component

changeEvent

childEvent

closeEvent

componentRange

Returns the range of valid values for the color widget’s component

componentValue

Returns the current value of the widget’s color component

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

hue

Returns the hue for the widget.

initPainter

inputMethodEvent

interiorMargin

Fetches the margin between the edge of the widget and the ramp

isSignalConnected

keyPressEvent

param event

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

param event

mousePressEvent

param event

mouseReleaseEvent

moveEvent

nativeEvent

orientation

Fetches the orientation for the color ramp

paintEvent

param event

receivers

resizeEvent

sender

senderSignalIndex

setInteriorMargin

Sets the margin between the edge of the widget and the ramp

setMarkerSize

Sets the size for drawing the triangular markers on the ramp

setOrientation

Sets the orientation for the color ramp

setShowFrame

Sets whether the ramp should be drawn within a frame

sharedPainter

showEvent

showFrame

Fetches whether the ramp is drawn within a frame

sizeHint

rtype

QSize

tabletEvent

timerEvent

transparentBackground

Generates a checkboard pattern pixmap for use as a background to transparent colors

updateMicroFocus

wheelEvent

param event

Signals

valueChanged

Emitted when the widget’s color component value changes

Attributes

Horizontal

Vertical

Horizontal = 0
class Orientation

Bases: int

Vertical = 1
actionEvent(self, QActionEvent)
alterColor(self, color: Union[QColor, Qt.GlobalColor, QGradient], component: QgsColorWidget.ColorComponent, newValue: int)

Alters a color by modifying the value of a specific color component

Parameters
  • color – color to alter

  • component – color component to alter

  • newValue – new value of color component. Values are automatically clipped to a valid range for the color component.

changeEvent(self, QEvent)
childEvent(self, QChildEvent)
closeEvent(self, QCloseEvent)
componentRange(self)int

Returns the range of valid values for the color widget’s component

Returns

maximum value allowed for color component, or -1 if widget has multiple components

componentRange(self, component: QgsColorWidget.ColorComponent) -> int Returns the range of valid values a color component

Returns

maximum value allowed for color component

componentValue(self)int

Returns the current value of the widget’s color component

Returns

value of color component, or -1 if widget has multiple components or an invalid color set

See also

setComponentValue()

See also

component()

componentValue(self, component: QgsColorWidget.ColorComponent) -> int Returns the value of a component of the widget’s current color. This method correctly handles hue values when the color has an ambiguous hue (e.g., black or white shades)

Parameters

component – color component to return

Returns

value of color component, or -1 if widget has an invalid color set

See also

hue()

connectNotify(self, QMetaMethod)
contextMenuEvent(self, QContextMenuEvent)
create(self, window: sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)
customEvent(self, QEvent)
destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)
disconnectNotify(self, QMetaMethod)
dragEnterEvent(self, e: QDragEnterEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dragMoveEvent(self, QDragMoveEvent)
dropEvent(self, e: QDropEvent)
enterEvent(self, QEvent)
event(self, QEvent)bool
focusInEvent(self, QFocusEvent)
focusNextChild(self)bool
focusNextPrevChild(self, bool)bool
focusOutEvent(self, QFocusEvent)
focusPreviousChild(self)bool
hideEvent(self, QHideEvent)
hue(self)int

Returns the hue for the widget. This may differ from the hue for the QColor returned by color(), as QColor returns a hue of -1 if the color’s hue is ambiguous (e.g., if the saturation is zero).

Returns

explicitly set hue for widget

initPainter(self, QPainter)
inputMethodEvent(self, QInputMethodEvent)
interiorMargin(self)int

Fetches the margin between the edge of the widget and the ramp

Return type

int

Returns

margin around the ramp

isSignalConnected(self, QMetaMethod)bool
keyPressEvent(self, event: QKeyEvent)
Parameters

event (QKeyEvent) –

keyReleaseEvent(self, QKeyEvent)
leaveEvent(self, QEvent)
metric(self, QPaintDevice.PaintDeviceMetric)int
mouseDoubleClickEvent(self, QMouseEvent)
mouseMoveEvent(self, event: QMouseEvent)
Parameters

event (QMouseEvent) –

mousePressEvent(self, event: QMouseEvent)
Parameters

event (QMouseEvent) –

mouseReleaseEvent(self, e: QMouseEvent)
moveEvent(self, QMoveEvent)
nativeEvent(self, Union[QByteArray, bytes, bytearray], sip.voidptr)Tuple[bool, int]
orientation(self)QgsColorRampWidget.Orientation

Fetches the orientation for the color ramp

Return type

QgsColorRampWidget.Orientation

Returns

orientation for the ramp

See also

setOrientation()

paintEvent(self, event: QPaintEvent)
Parameters

event (QPaintEvent) –

receivers(self, PYQT_SIGNAL)int
resizeEvent(self, QResizeEvent)
sender(self)QObject
senderSignalIndex(self)int
setInteriorMargin(self, margin: int)

Sets the margin between the edge of the widget and the ramp

Parameters

margin (int) – margin around the ramp

See also

interiorMargin()

setMarkerSize(self, markerSize: int)

Sets the size for drawing the triangular markers on the ramp

Parameters

markerSize (int) – marker size in pixels

setOrientation(self, orientation: QgsColorRampWidget.Orientation)

Sets the orientation for the color ramp

Parameters

orientation (QgsColorRampWidget.Orientation) – new orientation for the ramp

See also

orientation()

setShowFrame(self, showFrame: bool)

Sets whether the ramp should be drawn within a frame

Parameters

showFrame (bool) – set to True to draw a frame around the ramp

See also

showFrame()

sharedPainter(self)QPainter
showEvent(self, QShowEvent)
showFrame(self)bool

Fetches whether the ramp is drawn within a frame

Return type

bool

Returns

True if a frame is drawn around the ramp

See also

setShowFrame()

sizeHint(self)QSize
Return type

QSize

tabletEvent(self, QTabletEvent)
timerEvent(self, QTimerEvent)
transparentBackground()QPixmap

Generates a checkboard pattern pixmap for use as a background to transparent colors

Returns

checkerboard pixmap

updateMicroFocus(self)
valueChanged

Emitted when the widget’s color component value changes

Parameters

value (int) – new value of color component [signal]

wheelEvent(self, event: QWheelEvent)
Parameters

event (QWheelEvent) –