Class: QgsColorRampWidget

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%).

Class Hierarchy

Inheritance diagram of qgis.gui.QgsColorRampWidget

Base classes

QgsColorWidget

A base class for interactive color widgets.

QWidget

QObject

QPaintDevice

class qgis.gui.QgsColorRampWidget[source]

Bases: QgsColorWidget

__init__(parent: QWidget | None = None, component: QgsColorWidget.ColorComponent = QgsColorWidget.Red, orientation: QgsColorRampWidget.Orientation = QgsColorRampWidget.Horizontal)

Construct a new color ramp widget.

Parameters:
  • parent (Optional[QWidget] = None) – parent QWidget for the widget

  • component (QgsColorWidget.ColorComponent = QgsColorWidget.Red) – color component which varies along the ramp

  • orientation (QgsColorRampWidget.Orientation = QgsColorRampWidget.Horizontal) – orientation for widget

Horizontal = 0
class Orientation

Bases: int

Vertical = 1
interiorMargin(self) int[source]

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

Return type:

int

Returns:

margin around the ramp

orientation(self) QgsColorRampWidget.Orientation[source]

Fetches the orientation for the color ramp

Return type:

QgsColorRampWidget.Orientation

Returns:

orientation for the ramp

See also

setOrientation()

setInteriorMargin(self, margin: int)[source]

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)[source]

Sets the size for drawing the triangular markers on the ramp

Parameters:

markerSize (int) – marker size in pixels

setOrientation(self, orientation: QgsColorRampWidget.Orientation)[source]

Sets the orientation for the color ramp

Parameters:

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

See also

orientation()

setShowFrame(self, showFrame: bool)[source]

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()

showFrame(self) bool[source]

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()

signal valueChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal valueChangedF[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.