sleap.gui.widgets.slider

Drop-in replacement for QSlider with additional features.

class sleap.gui.widgets.slider.SemanticMarkType(value)[source]

An enumeration.

class sleap.gui.widgets.slider.SliderMark(type: str, val: float, end_val: float = None, row: int = None, track: Track = None, color: Union[tuple, str] = 'black')[source]

Class to hold data for an individual mark on the slider.

type

Type of the mark, options are: * “simple” (single value) * “simple_thin” ( ditto ) * “filled” * “open” * “predicted” * “tick” * “tick_column” * “track” (range of values)

val

Beginning of mark range

end_val

End of mark range (for “track” marks)

row

The row that the mark goes in; used for tracks.

color

Color of mark, can be string or (r, g, b) tuple.

filled

Whether the mark is shown filled (solid color).

property QColor

Returns color of mark as QColor.

property color

Returns color of mark.

property filled

Returns whether mark is filled or open.

class sleap.gui.widgets.slider.VideoSlider(orientation=- 1, min=0, max=1, val=0, marks=None, *args, **kwargs)[source]

Drop-in replacement for QSlider with additional features.

Parameters
  • orientation – ignored (here for compatibility with QSlider)

  • min – initial minimum value

  • max – initial maximum value

  • val – initial value

  • marks – initial set of values to mark on slider this can be either * list of values to mark * list of (track, value)-tuples to mark

Signals:

mousePressed: triggered on Qt event mouseMoved: triggered on Qt event mouseReleased: triggered on Qt event keyPress: triggered on Qt event keyReleased: triggered on Qt event valueChanged: triggered when value of slider changes selectionChanged: triggered when slider range selection changes heightUpdated: triggered when the height of slider changes

addMark(new_mark: sleap.gui.widgets.slider.SliderMark, update: bool = True)[source]

Adds a marked value to the slider.

Parameters
  • new_mark – value to mark

  • update – Whether to redraw slider with new mark.

Returns

None.

boundingRect() → PySide2.QtCore.QRectF[source]

Method required by Qt.

clearHeader()[source]

Remove header graph from slider.

clearMarks()[source]

Clears all marked values for slider.

clearSelection()[source]

Clears selection endpoints.

contiguousSelectionMarksAroundVal(val)[source]

Selects contiguously marked frames around value.

enabled()[source]

Returns whether slider is enabled.

endSelection(val, update: bool = False)[source]

Add final selection endpoint.

Called during or after the user is dragging to select range.

Parameters
  • val – value of endpoint

  • update

getEndContiguousMark(val: int) → int[source]

Returns last marked value in contiguously marked region around val.

getMarks(type: str = '')[source]

Returns list of marks.

getSelection()[source]

Returns start and end value of current selection endpoints.

getStartContiguousMark(val: int) → int[source]

Returns first marked value in contiguously marked region around val.

hasSelection() → bool[source]

Returns True if a clip is selected, False otherwise.

isMarkedVal(val: int) → bool[source]

Returns whether value has mark.

keyPressEvent(event)[source]

Catch event and emit signal so something else can handle event.

keyReleaseEvent(event)[source]

Catch event and emit signal so something else can handle event.

leaveEvent(self, event: PySide2.QtCore.QEvent)[source]
mouseDoubleClickEvent(event)[source]

Override method to move handle for mouse double-click.

Parameters

event

mouseMoveEvent(event)[source]

Override method to emit mouseMoved signal on drag.

mousePressEvent(event)[source]

Override method to move handle for mouse press/drag.

Parameters

event

mouseReleaseEvent(event)[source]

Override method to emit mouseReleased signal on release.

moveHandle(x, y)[source]

Move handle in response to mouse position.

Emits valueChanged signal if value of slider changed.

Parameters
  • x – x position of mouse

  • y – y position of mouse

moveSelectionAnchor(x: float, y: float)[source]

Moves selection anchor in response to mouse position.

Parameters
  • x – x position of mouse

  • y – y position of mouse

Returns

None.

paint(*args, **kwargs)[source]

Method required by Qt.

releaseSelectionAnchor(x, y)[source]

Finishes selection in response to mouse release.

Parameters
  • x – x position of mouse

  • y – y position of mouse

Returns

None.

removeMark(mark: sleap.gui.widgets.slider.SliderMark)[source]

Removes an individual mark.

resizeEvent(event=None)[source]

Override method to update visual size when necessary.

Parameters

event

setEnabled(val: float) → float[source]

Set whether the slider is enabled.

setHeaderSeries(series: Optional[Dict[int, float]] = None)[source]

Show header graph with specified series.

Parameters

series – {frame number: series value} dict.

Returns

None.

setMarks(marks: Iterable[Union[sleap.gui.widgets.slider.SliderMark, int]])[source]

Sets all marked values for the slider.

Parameters

marks – iterable with all values to mark

Returns

None.

setMaximum(max: float) → float[source]

Sets maximum value for slider.

setMinimum(min: float) → float[source]

Sets minimum value for slider.

setNumberOfTracks(track_rows)[source]

Set the number of tracks to show in slider.

Parameters

track_rows – the number of tracks to show

setSelection(start_val, end_val)[source]

Selects clip from start_val to end_val.

setTickMarks()[source]

Resets which tick marks to show.

setTooltipCallable(tooltip_callable: Callable)[source]

Sets function to get tooltip text for given value in slider.

Parameters

tooltip_callable – a function which takes the value which the user is hovering over and returns the tooltip text to show (if any)

setValue(val: float) → float[source]

Sets value of slider.

property slider_visible_value_range

Value range that’s visible given current size and zoom.

startSelection(val)[source]

Adds initial selection endpoint.

Called when user starts dragging to select range in slider.

Parameters

val – value of endpoint

value() → float[source]

Returns value of slider.

sleap.gui.widgets.slider.set_slider_marks_from_labels(slider: sleap.gui.widgets.slider.VideoSlider, labels: Labels, video: Video, color_manager: Optional[sleap.gui.color.ColorManager] = None)[source]

Sets slider marks using track information from Labels object.

Parameters
  • slider – the slider we’re updating

  • labels – the dataset with tracks and labeled frames

  • video – the video for which to show marks

Returns

None