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. |
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 |
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. |
Return a ColorMap object representing the current state of the editor.
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. |
Return a QLinearGradient object.
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. |
Return True if the gradient has exactly two stops in it: black at 0.0 and white at 1.0
Load a predefined gradient.
Restore the gradient specified in state.
Arguments | |
state | A dictionary with same structure as those returned by saveState Keys must include:
|
Return a dictionary with parameters for rebuilding the gradient. Keys will include:
Set the color mode for the gradient. Options are: ‘hsv’, ‘rgb’
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’). |
Return True if any ticks have an alpha < 255
Bases: GraphicsWidget
A rectangular item with tick marks along its length that can (optionally) be moved by the user.
Arguments | |
orientation | Set the orientation of the gradient. Options are: ‘left’, ‘right’ ‘top’, and ‘bottom’. |
allowAdd | Specifies whether ticks can be added to the item by the user. |
tickPen | Default is white. Specifies the color of the outline of the ticks. Can be any of the valid arguments for mkPen |
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. |
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. |
Return a sorted list of all the Tick objects on the slider.
Removes the specified tick.
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’). |
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 |
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. |
Return the value (from 0.0 to 1.0) 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 the value of the middle tick, the index would be 1. |