sleap.gui.dialogs.importvideos

Interface to handle the UI for importing videos.

Usage:

>>> import_list = ImportVideos().ask()

This will show the user a file-selection dialog, and then a second dialog to select the import parameters for each file.

It returns a list with data about each file selected by the user. In particular, we’ll have the name of the file and all of the parameters relevant for that specific type of file. It also includes a reference to the relevant method of Video.

For each item in import_list, we can load the video by calling this method while passing the user-selected params as the named parameters:

>>> vid = item["video_class"](**item["params"])
class sleap.gui.dialogs.importvideos.ImportItemWidget(file_path: str, import_type: dict, *args, **kwargs)[source]

Widget for selecting parameters with preview when importing video.

Parameters
  • file_path (str) – Full path to selected video file.

  • import_type (dict) – Data about user-selectable import parameters.

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

Method required by Qt.

get_data() → dict[source]

Get all data (fixed and user-selected) for imported video.

Returns

Dict with data for this video.

is_enabled()[source]

Am I enabled?

Our UI provides a way to enable/disable this item (file). We only want to import enabled items.

Returns

Am I enabled?

Return type

Boolean

paint(painter, option, widget=None)[source]

Method required by Qt.

update_video(initial: bool = False)[source]

Update preview video using current param values.

Parameters

initial – if True, then get video settings that are used by the Video object when they aren’t specified as params

Returns

None.

class sleap.gui.dialogs.importvideos.ImportParamDialog(filenames: list, *args, **kwargs)[source]

Dialog for selecting parameters with preview when importing video.

Parameters

filenames (list) – List of files we want to import.

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

Method required by Qt.

get_data(import_result=None)[source]

Method to get results from import.

Parameters

import_result (optional) – If specified, we’ll insert data into this.

Returns

List of dicts with data for each (enabled) imported file.

paint(painter, option, widget=None)[source]

Method required by Qt.

class sleap.gui.dialogs.importvideos.ImportParamWidget(file_path: str, import_type: dict, *args, **kwargs)[source]

Widget for allowing user to select video parameters.

Parameters
  • file_path – file path/name

  • import_type – data about the parameters for this type of video

Note

Object is a widget with the UI for params specific to this video type.

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

Method required by Qt.

get_values(only_required=False)[source]

Method to get current user-selected values for import parameters.

Parameters

only_required – Only return the parameters that are required for instantiating Video object

Returns

Dict of param keys/values.

Note

It’s easiest if the return dict matches the arguments we need for the Video object, so we’ll add the file name to the dict even though it’s not a user-selectable param.

make_layout() → PySide2.QtWidgets.QLayout[source]

Builds the layout of widgets for user-selected import parameters.

paint(painter, option, widget=None)[source]

Method required by Qt.

set_values_from_video(video)[source]

Set the form fields using attributes on video.

class sleap.gui.dialogs.importvideos.ImportVideos[source]

Class to handle video importing UI.

ask()[source]

Runs the import UI.

  1. Show file selection dialog.

  2. Show import parameter dialog with widget for each file.

Parameters

None.

Returns

List with dict of the parameters for each file to import.

class sleap.gui.dialogs.importvideos.VideoPreviewWidget(video: sleap.io.video.Video = None, *args, **kwargs)[source]

Widget to show video preview. Based on Video class.

Parameters

video – the video to show

Returns

None.

Note

This widget is used by ImportItemWidget.

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

Method required by Qt.

clear_video()[source]

Clear the video preview.

load_video(video: sleap.io.video.Video, initial_frame=0, plot=True)[source]

Load the video preview and display label text.

paint(painter, option, widget=None)[source]

Method required by Qt.

plot(idx=0)[source]

Show the video preview.