sleap.gui.widgets.slider¶
Drop-in replacement for QSlider with additional features.
-
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.
-
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.
-
getStartContiguousMark
(val: int) → int[source]¶ Returns first marked value in contiguously marked region around val.
-
mouseDoubleClickEvent
(event)[source]¶ Override method to move handle for mouse double-click.
- Parameters
event –
-
mousePressEvent
(event)[source]¶ Override method to move handle for mouse press/drag.
- Parameters
event –
-
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.
-
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 –
-
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.
-
setNumberOfTracks
(track_rows)[source]¶ Set the number of tracks to show in slider.
- Parameters
track_rows – the number of tracks 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)
-
property
slider_visible_value_range
¶ Value range that’s visible given current size and zoom.
-
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