Subgroup: Color

Class: QgsColorRampButton

class qgis.gui.QgsColorRampButton

Bases: PyQt5.QtWidgets.QToolButton

A cross platform button subclass for selecting color ramps. Will open color ramp dialogs when clicked. Offers live updates to button from color ramp dialog. An attached drop-down menu allows for access to saved color ramps, as well as option to invert the current color ramp and create new ramps.

New in version 3.0: Methods

acceptDrops
acceptLiveUpdates Returns whether the button accepts live updates from QgsColorRampDialog.
accessibleDescription
accessibleName
actionEvent
actions
activateWindow
addAction
addActions
adjustSize
animateClick
arrowType
autoExclusive
autoFillBackground
autoRaise
autoRepeat
autoRepeatDelay
autoRepeatInterval
backgroundRole
baseSize
blockSignals
changeEvent
checkStateSet
childAt childAt(self, int, int) -> QWidget
childEvent
children
childrenRect
childrenRegion
clearFocus
clearMask
click
close
closeEvent
colorCount
colorRamp Return a copy of the current color ramp.
colorRampDialogTitle Returns the title for the color ramp dialog window.
colorRampName Returns the name of the current color ramp when it’s available in the style manager
connectNotify
contentsMargins
contentsRect
context Returns the context string for the color ramp button.
contextMenuEvent
contextMenuPolicy
create
createWindowContainer
cursor
customEvent
defaultAction
defaultColorRamp Returns a copy of the default color ramp for the button, which is shown in the button’s drop-down menu for the “default color ramp” option.
deleteLater
depth
destroy
devType
devicePixelRatio
devicePixelRatioF
devicePixelRatioFScale
disconnect
disconnectNotify
dragEnterEvent
dragLeaveEvent
dragMoveEvent
dropEvent
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
effectiveWinId
ensurePolished
enterEvent
event
eventFilter
find
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
focusInEvent
focusNextChild
focusNextPrevChild
focusOutEvent
focusPolicy
focusPreviousChild
focusProxy
focusWidget
font
fontInfo
fontMetrics
foregroundRole
frameGeometry
frameSize
geometry
getContentsMargins
grab
grabGesture
grabKeyboard
grabMouse grabMouse(self, Union[QCursor, Qt.CursorShape])
grabShortcut
graphicsEffect
graphicsProxyWidget
group
hasFocus
hasHeightForWidth
hasMouseTracking
hasTabletTracking
height
heightForWidth
heightMM
hide
hideEvent
hitButton
icon
iconSize
inherits
initPainter
initStyleOption
inputMethodEvent
inputMethodHints
inputMethodQuery
insertAction
insertActions
installEventFilter
isActiveWindow
isAncestorOf
isCheckable
isChecked
isDown
isEnabled
isEnabledTo
isFullScreen
isHidden
isLeftToRight
isMaximized
isMinimized
isModal
isNull Returns true if the current color is null.
isRandomColorRamp Returns true if the current color is null.
isRightToLeft
isSignalConnected
isVisible
isVisibleTo
isWidgetType
isWindow
isWindowModified
isWindowType
keyPressEvent
keyReleaseEvent
keyboardGrabber
killTimer
layout
layoutDirection
leaveEvent
locale
logicalDpiX
logicalDpiY
lower
mapFrom
mapFromGlobal
mapFromParent
mapTo
mapToGlobal
mapToParent
mask
maximumHeight
maximumSize
maximumWidth
menu
metaObject
metric
minimumHeight
minimumSize
minimumSizeHint
minimumWidth
mouseDoubleClickEvent
mouseGrabber
mouseMoveEvent
mousePressEvent Reimplemented to detect right mouse button clicks on the color ramp button
mouseReleaseEvent
move move(self, int, int)
moveEvent
moveToThread
nativeEvent
nativeParentWidget
nextCheckState
nextInFocusChain
normalGeometry
objectName
overrideWindowFlags
overrideWindowState
paintEngine
paintEvent
paintingActive
palette
parent
parentWidget
physicalDpiX
physicalDpiY
popupMode
pos
previousInFocusChain
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
raise_
receivers
rect
releaseKeyboard
releaseMouse
releaseShortcut
removeAction
removeEventFilter
render render(self, QPainter, targetOffset: QPoint = QPoint(), sourceRegion: QRegion = QRegion(), flags: Union[QWidget.RenderFlags, QWidget.RenderFlag] = QWidget.RenderFlags(QWidget.DrawWindowBackground|QWidget.DrawChildren))
repaint repaint(self, int, int, int, int)
resize resize(self, int, int)
resizeEvent
restoreGeometry
saveGeometry
scroll scroll(self, int, int, QRect)
sender
senderSignalIndex
setAcceptDrops
setAcceptLiveUpdates Sets whether the button accepts live updates from QgsColorRampDialog.
setAccessibleDescription
setAccessibleName
setArrowType
setAttribute
setAutoExclusive
setAutoFillBackground
setAutoRaise
setAutoRepeat
setAutoRepeatDelay
setAutoRepeatInterval
setBackgroundRole
setBaseSize setBaseSize(self, QSize)
setButtonBackground Sets the background pixmap for the button based upon current color ramp.
setCheckable
setChecked
setColorRamp Sets the current color ramp for the button.
setColorRampDialogTitle Set the title for the color ramp dialog window.
setColorRampFromName Sets the current color ramp for the button using a saved color ramp name.
setColorRampName Sets the name of the current color ramp when it’s available in the style manager
setContentsMargins setContentsMargins(self, QMargins)
setContext Sets the context string for the color ramp button.
setContextMenuPolicy
setCursor
setDefaultAction
setDefaultColorRamp Sets the default color ramp for the button, which is shown in the button’s drop-down menu for the “default color ramp” option.
setDisabled
setDown
setEnabled
setFixedHeight
setFixedSize setFixedSize(self, int, int)
setFixedWidth
setFocus setFocus(self, Qt.FocusReason)
setFocusPolicy
setFocusProxy
setFont
setForegroundRole
setGeometry setGeometry(self, int, int, int, int)
setGraphicsEffect
setHidden
setIcon
setIconSize
setInputMethodHints
setLayout
setLayoutDirection
setLocale
setMask setMask(self, QRegion)
setMaximumHeight
setMaximumSize setMaximumSize(self, QSize)
setMaximumWidth
setMenu
setMinimumHeight
setMinimumSize setMinimumSize(self, QSize)
setMinimumWidth
setMouseTracking
setObjectName
setPalette
setParent setParent(self, QWidget, Union[Qt.WindowFlags, Qt.WindowType])
setPopupMode
setProperty
setRandomColorRamp Sets the current color ramp for the button to random colors.
setShortcut
setShortcutAutoRepeat
setShortcutEnabled
setShowGradientOnly Sets whether the color ramp button only shows gradient type ramps
setShowMenu Sets whether the drop-down menu should be shown for the button.
setShowNull Sets whether a set to null (clear) option is shown in the button’s drop-down menu.
setShowRandomColorRamp Sets whether a random colors option is shown in the button’s drop-down menu.
setSizeIncrement setSizeIncrement(self, QSize)
setSizePolicy setSizePolicy(self, QSizePolicy.Policy, QSizePolicy.Policy)
setStatusTip
setStyle
setStyleSheet
setTabOrder
setTabletTracking
setText
setToDefaultColorRamp Sets color ramp to the button’s default color ramp, if set.
setToNull Sets color ramp to null.
setToolButtonStyle
setToolTip
setToolTipDuration
setUpdatesEnabled
setVisible
setWhatsThis
setWindowFilePath
setWindowFlag
setWindowFlags
setWindowIcon
setWindowIconText
setWindowModality
setWindowModified
setWindowOpacity
setWindowRole
setWindowState
setWindowTitle
sharedPainter
shortcut
show
showEvent
showFullScreen
showGradientOnly Returns true if the color ramp button only shows gradient type ramps
showMaximized
showMenu Returns whether the drop-down menu is shown for the button.
showMinimized
showNormal
showNull Returns whether the set to null (clear) option is shown in the button’s drop-down menu.
showRandomColorRamp Returns whether random colors option is shown in the button’s drop-down menu.
signalsBlocked
size
sizeHint
sizeIncrement
sizePolicy
stackUnder
startTimer
statusTip
style
styleSheet
tabletEvent
testAttribute
text
thread
timerEvent
toggle
toolButtonStyle
toolTip
toolTipDuration
tr
underMouse
ungrabGesture
unsetCursor
unsetLayoutDirection
unsetLocale
update update(self, QRect)
updateGeometry
updateMicroFocus
updatesEnabled
visibleRegion
whatsThis
wheelEvent
width
widthMM
winId
window
windowFilePath
windowFlags
windowHandle
windowIcon
windowIconText
windowModality
windowOpacity
windowRole
windowState
windowTitle
windowType
x
y

Attributes

DelayedPopup
DrawChildren
DrawWindowBackground
IgnoreMask
InstantPopup
MenuButtonPopup
PdmDepth
PdmDevicePixelRatio
PdmDevicePixelRatioScaled
PdmDpiX
PdmDpiY
PdmHeight
PdmHeightMM
PdmNumColors
PdmPhysicalDpiX
PdmPhysicalDpiY
PdmWidth
PdmWidthMM
clicked clicked(self, bool = False) [signal]
colorRampChanged Emitted whenever a new color ramp is set for the button.
customContextMenuRequested customContextMenuRequested(self, QPoint) [signal]
destroyed destroyed(self, QObject = None) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
pressed pressed(self) [signal]
released released(self) [signal]
staticMetaObject
toggled toggled(self, bool) [signal]
triggered triggered(self, QAction) [signal]
windowIconChanged windowIconChanged(self, QIcon) [signal]
windowIconTextChanged windowIconTextChanged(self, str) [signal]
windowTitleChanged windowTitleChanged(self, str) [signal]
acceptLiveUpdates(self) → bool

Returns whether the button accepts live updates from QgsColorRampDialog.

Returns:true if the button will be accepted immediately when the dialog’s color ramp changes
actionEvent()
changeEvent(self, e: QEvent)
checkStateSet()
childEvent()
closeEvent()
colorRamp(self) → QgsColorRamp

Return a copy of the current color ramp.

See also

setColorRamp()

colorRampChanged

Emitted whenever a new color ramp is set for the button. The color ramp is always valid. In case the new color ramp is the same, no signal is emitted to avoid infinite loops. [signal]

colorRampDialogTitle(self) → str

Returns the title for the color ramp dialog window.

Returns:title for the color ramp dialog
colorRampName(self) → str

Returns the name of the current color ramp when it’s available in the style manager

connectNotify()
context(self) → str

Returns the context string for the color ramp button. The context string is passed to all color ramp preview icons shown in the button’s drop-down menu, to (eventually) allow them to customise their display colors based on the context.

Returns:context context string for the color dialog button’s color ramp preview icons

See also

setContext()

contextMenuEvent()
create()
customEvent()
defaultColorRamp(self) → QgsColorRamp

Returns a copy of the default color ramp for the button, which is shown in the button’s drop-down menu for the “default color ramp” option.

Returns:default color ramp for the button. Returns a null pointer if the default color ramp

option is disabled.

destroy()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
enterEvent()
event(self, e: QEvent) → bool
focusInEvent()
focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
hideEvent()
hitButton()
initPainter()
initStyleOption()
inputMethodEvent()
isNull(self) → bool

Returns true if the current color is null.

See also

setShowNull()

See also

showNull()

isRandomColorRamp(self) → bool

Returns true if the current color is null.

See also

setShowNull()

See also

showNull()

isSignalConnected()
keyPressEvent()
keyReleaseEvent()
leaveEvent()
metric()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent(self, e: QMouseEvent)

Reimplemented to detect right mouse button clicks on the color ramp button

mouseReleaseEvent()
moveEvent()
nativeEvent()
nextCheckState()
paintEvent()
receivers()
resizeEvent(self, event: QResizeEvent)
sender()
senderSignalIndex()
setAcceptLiveUpdates(self, accept: bool)

Sets whether the button accepts live updates from QgsColorRampDialog. Live updates may cause changes that are not undoable on QColorRampDialog cancel.

Parameters:accept – set to true to enable live updates
setButtonBackground(self, colorramp: QgsColorRamp = None)

Sets the background pixmap for the button based upon current color ramp.

Parameters:colorramp – Color ramp for button background. If no color ramp is specified, the button’s current

color ramp will be used

setColorRamp(self, colorramp: QgsColorRamp)

Sets the current color ramp for the button. Will emit a colorRampChanged() signal if the color ramp is different to the previous color ramp.

Parameters:colorramp – New color ramp for the button. The ramp will be cloned and ownership is not transferred.
setColorRampDialogTitle(self, title: str)

Set the title for the color ramp dialog window.

Parameters:title – Title for the color ramp dialog
setColorRampFromName(self, name: str = '')

Sets the current color ramp for the button using a saved color ramp name. Will emit a colorRampChanged() signal if the color ramp is different to the previous color ramp.

Parameters:name – Name of saved color ramp

See also

setColorRamp()

setColorRampName(self, name: str)

Sets the name of the current color ramp when it’s available in the style manager

Parameters:name – Name of the saved color ramp

See also

colorRampName()

setContext(self, context: str)

Sets the context string for the color ramp button. The context string is passed to all color ramp preview icons shown in the button’s drop-down menu, to (eventually) allow them to customise their display colors based on the context.

Parameters:context – context string for the color dialog button’s color ramp preview icons

See also

context()

setDefaultColorRamp(self, colorramp: QgsColorRamp)

Sets the default color ramp for the button, which is shown in the button’s drop-down menu for the “default color ramp” option.

Parameters:colorramp – default color ramp for the button. Set to a null pointer to disable the default color

ramp option. The ramp will be cloned and ownership is not transferred.

setRandomColorRamp(self)

Sets the current color ramp for the button to random colors. Will emit a colorRampChanged() signal if the color ramp is different to the previous color ramp.

See also

setColorRamp()

setShowGradientOnly(self, gradientonly: bool)

Sets whether the color ramp button only shows gradient type ramps

Parameters:gradientonly – set to true to show only gradient type ramps
setShowMenu(self, showMenu: bool)

Sets whether the drop-down menu should be shown for the button. The default behavior is to show the menu.

Parameters:showMenu – set to false to hide the drop-down menu

See also

showMenu()

setShowNull(self, showNull: bool)

Sets whether a set to null (clear) option is shown in the button’s drop-down menu.

Parameters:showNull – set to true to show a null option

See also

showNull()

See also

isNull()

setShowRandomColorRamp(self, showRandom: bool)

Sets whether a random colors option is shown in the button’s drop-down menu.

Parameters:showRandom – set to true to show a random colors option

See also

showRandom()

setToDefaultColorRamp(self)

Sets color ramp to the button’s default color ramp, if set.

See also

setToNull()

setToNull(self)

Sets color ramp to null.

sharedPainter()
showEvent(self, e: QShowEvent)
showGradientOnly(self) → bool

Returns true if the color ramp button only shows gradient type ramps

showMenu(self) → bool

Returns whether the drop-down menu is shown for the button.

Returns:true if drop-down menu is shown

See also

setShowMenu()

showNull(self) → bool

Returns whether the set to null (clear) option is shown in the button’s drop-down menu.

See also

setShowNull()

See also

isNull()

showRandomColorRamp(self) → bool

Returns whether random colors option is shown in the button’s drop-down menu.

See also

setShowRandom()

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