GradientEditorItem — pyqtgraph 0.11.0rc0 documentation

# 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.

  `colorMap`()

    Return a ColorMap object representing the current state of the editor.

  `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.

  `getGradient`()

    Return a QLinearGradient object.

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

    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: odict_keys([‘thermal’, ‘flame’, ‘yellowy’, ‘bipolar’, ‘spectrum’, ‘cyclic’, ‘greyclip’, ‘grey’, ‘viridis’, ‘inferno’, ‘plasma’, ‘magma’])

  `mouseReleaseEvent`(self, event: PySide2.QtWidgets.QGraphicsSceneMouseEvent)
  `removeTick`(tick, finish=True)

    Removes the specified tick.

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

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

  `setColorMode`(cm)

    Set the color mode for the gradient. Options are: ‘hsv’, ‘rgb’

  `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’).

  `usesAlpha`()

    Return True if any ticks have an alpha < 255

# TickSliderItem

class `pyqtgraph.` `TickSliderItem`(orientation='bottom', allowAdd=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, **kargs)

    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`

  `addTick`(x, color=None, movable=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.

  `keyPressEvent`(self, event: PySide2.QtGui.QKeyEvent)
  `listTicks`()

    Return a sorted list of all the Tick objects on the slider.

  `paint`(self, painter: PySide2.QtGui.QPainter, option: PySide2.QtWidgets.QStyleOptionGraphicsItem, widget: typing.Union[PySide2.QtWidgets.QWidget, NoneType] = None)
  `removeTick`(tick)

    Removes the specified tick.

  `resizeEvent`(self, event: PySide2.QtWidgets.QGraphicsSceneResizeEvent)
  `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.

  `tickValue`(tick)

    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.