GradientEditorItem#
- class pyqtgraph.GradientEditorItem(
- *args,
- **kargs,
Bases:
TickSliderItem
An item that can be used to define a color gradient. Implements common pre-defined gradients that are customizable by the user. :class: GradientWidget <pyqtgraph.GradientWidget> provides a widget with a GradientEditorItem that can be added to a GUI.
Signals:
sigGradientChanged(self)
Signal is emitted anytime the gradient changes. The signal is emitted in real time while ticks are being dragged or colors are being changed.
sigGradientChangeFinished(self)
Signal is emitted when the gradient is finished changing.
- __init__(
- *args,
- **kargs,
Create a new GradientEditorItem. All arguments are passed to
TickSliderItem.__init__
Arguments:
orientation
Set the orientation of the gradient. Options are: ‘left’, ‘right’ ‘top’, and ‘bottom’.
allowAdd
Default is True. Specifies whether ticks can be added to the item.
tickPen
Default is white. Specifies the color of the outline of the ticks. Can be any of the valid arguments for
mkPen
- addTick(
- x,
- color=None,
- movable=True,
- finish=True,
Add a tick to the gradient. Return the tick.
Arguments:
x
Position where tick should be added.
color
Color of added tick. If color is not specified, the color will be the color of the gradient at the specified position.
movable
Specifies whether the tick is movable with the mouse.
- getColor(
- x,
- toQColor=True,
Return a color for a given value.
Arguments:
x
Value (position on gradient) of requested color.
toQColor
If true, returns a QColor object, else returns a (r,g,b,a) tuple.
- getLookupTable(
- nPts,
- alpha=None,
Return an RGB(A) lookup table (ndarray).
Arguments:
nPts
The number of points in the returned lookup table.
alpha
True, False, or None - Specifies whether or not alpha values are included in the table.If alpha is None, alpha will be automatically determined.
- isLookupTrivial()[source]#
Return True if the gradient has exactly two stops in it: black at 0.0 and white at 1.0
- loadPreset(
- name,
Load a predefined gradient. Currently defined gradients are: ‘thermal’, ‘flame’, ‘yellowy’, ‘bipolar’, ‘spectrum’, ‘cyclic’, ‘greyclip’, ‘grey’, ‘viridis’, ‘inferno’, ‘plasma’, ‘magma’, ‘turbo’
- restoreState(
- state,
Restore the gradient specified in state.
Arguments:
state
A dictionary with same structure as those returned by
saveState
Keys must include:
‘mode’: hsv or rgb
‘ticks’: a list of tuples (pos, (r,g,b,a))
- saveState()[source]#
Return a dictionary with parameters for rebuilding the gradient. Keys will include:
‘mode’: hsv or rgb
‘ticks’: a list of tuples (pos, (r,g,b,a))
- setOrientation(
- orientation,
Set the orientation of the GradientEditorItem.
Arguments:
orientation
Options are: ‘left’, ‘right’, ‘top’, ‘bottom’ The orientation option specifies which side of the gradient the ticks are on, as well as whether the gradient is vertical (‘right’ and ‘left’) or horizontal (‘top’ and ‘bottom’).
TickSliderItem#
- class pyqtgraph.TickSliderItem(
- orientation='bottom',
- allowAdd=True,
- allowRemove=True,
- **kargs,
Bases:
GraphicsWidget
A rectangular item with tick marks along its length that can (optionally) be moved by the user.
- __init__(
- orientation='bottom',
- allowAdd=True,
- allowRemove=True,
- **kargs,
Arguments:
orientation
Set the orientation of the gradient. Options are: ‘left’, ‘right’ ‘top’, and ‘bottom’.
allowAdd
Specifies whether the user can add ticks.
allowRemove
Specifies whether the user can remove new ticks.
tickPen
Default is white. Specifies the color of the outline of the ticks. Can be any of the valid arguments for
mkPen
- addTick(
- x,
- color=None,
- movable=True,
- finish=True,
Add a tick to the item.
Arguments:
x
Position where tick should be added.
color
Color of added tick. If color is not specified, the color will be white.
movable
Specifies whether the tick is movable with the mouse.
- getTick(
- tick,
Return the Tick object at the specified index.
Arguments:
tick
An integer corresponding to the index of the desired tick. If the argument is not an integer it will be returned unchanged.
- setOrientation(
- orientation,
Set the orientation of the TickSliderItem.
Arguments:
orientation
Options are: ‘left’, ‘right’, ‘top’, ‘bottom’ The orientation option specifies which side of the slider the ticks are on, as well as whether the slider is vertical (‘right’ and ‘left’) or horizontal (‘top’ and ‘bottom’).
- setTickColor(
- tick,
- color,
Set the color of the specified tick.
Arguments:
tick
Can be either an integer corresponding to the index of the tick or a Tick object. Ex: if you had a slider with 3 ticks and you wanted to change the middle tick, the index would be 1.
color
The color to make the tick. Can be any argument that is valid for
mkBrush
- setTickValue(
- tick,
- val,
Set the position (along the slider) of the tick.
Arguments:
tick
Can be either an integer corresponding to the index of the tick or a Tick object. Ex: if you had a slider with 3 ticks and you wanted to change the middle tick, the index would be 1.
val
The desired position of the tick. If val is < 0, position will be set to 0. If val is > 1, position will be set to 1.