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.
QgsColorRampButton(parent: QWidget = None, dialogTitle: str = ‘’) Construct a new color ramp button. Use
parent
to attach a parent QWidget to the dialog. UsedialogTitle
string to define the title to show in the color ramp dialogMethods
Returns whether the button accepts live updates from
QgsColorRampDialog
.- param e:
Returns a copy of the current color ramp.
Returns the title for the color ramp dialog window.
Returns the name of the current color ramp when it's available in the style manager
Returns the context string for the color ramp button.
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.
- param e:
Returns
True
if the current color ramp is null.Returns
True
if the current color ramp is random.Reimplemented to detect right mouse button clicks on the color ramp button
- param event:
Sets whether the button accepts live updates from
QgsColorRampDialog
.Sets the background pixmap for the button based upon current color ramp.
Sets the current color ramp for the button.
Set the title for the color ramp dialog window.
Sets the current color ramp for the button using a saved color ramp name.
Sets the name of the current color ramp when it's available in the style manager
Sets the context string for the color ramp button.
Sets the default color ramp for the button, which is shown in the button's drop-down menu for the "default color ramp" option.
Sets the current color ramp for the button to random colors.
Sets whether the color ramp button only shows gradient type ramps
Sets whether the drop-down menu should be shown for the button.
Sets whether a set to null (clear) option is shown in the button's drop-down menu.
Sets whether a random colors option is shown in the button's drop-down menu.
Sets color ramp to the button's default color ramp, if set.
Sets color ramp to null.
- param e:
Returns
True
if the color ramp button only shows gradient type rampsReturns whether the drop-down menu is shown for the button.
Returns whether the set to null (clear) option is shown in the button's drop-down menu.
Returns whether random colors option is shown in the button's drop-down menu.
- rtype:
QSize
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- acceptLiveUpdates(self) bool ¶
Returns whether the button accepts live updates from
QgsColorRampDialog
.- Return type:
bool
- Returns:
True
if the button will be accepted immediately when the dialog’s color ramp changes
See also
- actionEvent(self, QActionEvent)¶
- changeEvent(self, e: QEvent)¶
- Parameters:
e (QEvent) –
- checkStateSet(self)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- colorRamp(self) QgsColorRamp ¶
Returns a copy of the current color ramp.
See also
- Return type:
- colorRampChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- colorRampDialogTitle(self) str ¶
Returns the title for the color ramp dialog window.
- Return type:
str
- Returns:
title for the color ramp dialog
See also
- colorRampName(self) str ¶
Returns the name of the current color ramp when it’s available in the style manager
See also
- Return type:
str
- connectNotify(self, QMetaMethod)¶
- 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 customize their display colors based on the context.
- Return type:
str
- Returns:
context context string for the color dialog button’s color ramp preview icons
See also
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- 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.
- Return type:
- Returns:
default color ramp for the button. Returns
None
if the default color ramp option is disabled. Caller takes ownership of the returned object.
See also
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enterEvent(self, QEvent)¶
- event(self, e: QEvent) bool ¶
- Parameters:
e (QEvent) –
- Return type:
bool
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- hideEvent(self, QHideEvent)¶
- hitButton(self, QPoint) bool ¶
- initPainter(self, QPainter)¶
- initStyleOption(self, QStyleOptionToolButton)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isNull(self) bool ¶
Returns
True
if the current color ramp is null.See also
See also
- Return type:
bool
- isRandomColorRamp(self) bool ¶
Returns
True
if the current color ramp is random.See also
See also
- Return type:
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, e: QMouseEvent)¶
Reimplemented to detect right mouse button clicks on the color ramp button
- Parameters:
e (QMouseEvent) –
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- nextCheckState(self)¶
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- resizeEvent(self, event: QResizeEvent)¶
- Parameters:
event (QResizeEvent) –
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- 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 (bool) – set to
True
to enable live updates
See also
- setButtonBackground(self, colorramp: QgsColorRamp = None)¶
Sets the background pixmap for the button based upon current color ramp.
- Parameters:
colorramp (
QgsColorRamp
= None) – 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 (QgsColorRamp) – New color ramp for the button. The ramp will be cloned and ownership is not transferred.
See also
- setColorRampDialogTitle(self, title: str)¶
Set the title for the color ramp dialog window.
- Parameters:
title (str) – Title for the color ramp dialog
See also
- 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 (str = '') – Name of saved color ramp
See also
- setColorRampName(self, name: str)¶
Sets the name of the current color ramp when it’s available in the style manager
- Parameters:
name (str) – Name of the saved color ramp
See also
- 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 customize their display colors based on the context.
- Parameters:
context (str) – context string for the color dialog button’s color ramp preview icons
See also
- 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 (QgsColorRamp) – default color ramp for the button. Set to
None
to disable the default color ramp option. The ramp will be cloned and ownership is not transferred.
See also
- 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
- setShowGradientOnly(self, gradientonly: bool)¶
Sets whether the color ramp button only shows gradient type ramps
- Parameters:
gradientonly (bool) – set to
True
to show only gradient type ramps
See also
- 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 (bool) – set to
False
to hide the drop-down menu
See also
- setShowNull(self, showNull: bool)¶
Sets whether a set to null (clear) option is shown in the button’s drop-down menu.
- Parameters:
showNull (bool) – set to
True
to show a null option
See also
See also
- setShowRandomColorRamp(self, showRandom: bool)¶
Sets whether a random colors option is shown in the button’s drop-down menu.
- Parameters:
showRandom (bool) – set to
True
to show a random colors option
See also
- setToDefaultColorRamp(self)¶
Sets color ramp to the button’s default color ramp, if set.
See also
See also
See also
- setToNull(self)¶
Sets color ramp to null.
See also
- showEvent(self, e: QShowEvent)¶
- Parameters:
e (QShowEvent) –
- showGradientOnly(self) bool ¶
Returns
True
if the color ramp button only shows gradient type rampsSee also
- Return type:
bool
- showMenu(self) bool ¶
Returns whether the drop-down menu is shown for the button.
- Return type:
bool
- Returns:
True
if drop-down menu is shown
See also
- showNull(self) bool ¶
Returns whether the set to null (clear) option is shown in the button’s drop-down menu.
See also
See also
- Return type:
bool
- showRandomColorRamp(self) bool ¶
Returns whether random colors option is shown in the button’s drop-down menu.
See also
- Return type:
bool
- sizeHint(self) QSize ¶
- Return type:
QSize
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- updateMicroFocus(self)¶
- wheelEvent(self, QWheelEvent)¶