SelectDatasetTree

Introduction

The SelectDatasetTree widget in Supervisely is a user interface element that allows users to select datasets from a tree-like structure that can be useful when working with hierarchical data. The SelectDatasetTree widget has event handlers that are triggered when selected datasets are changed. This can be useful for applications that require dynamic change handling, such as showing data from the selected items.

Read this tutorial in the developer portal.

Function signature

SelectDatasetTree(
    default_id = None,
    project_id = None,
    multiselect = False,
    compact = False,
    select_all_datasets = False,
    allowed_project_types = None,
    flat = False,
    always_open = False,
    team_is_selectable = True,
    workspace_is_selectable = True,
    append_to_body = True,
    widget_id = None,
)
default

Parameters

Parameters
Type
Description

default_id

Optional[int]

The default dataset ID to be selected when the widget is initialized.

project_id

Optional[int]

The project ID to be displayed in the widget.

multiselect

bool

If True, multiple datasets can be selected. Default is False.

compact

bool

If True, the widget will be displayed in compact mode. Default is False.

select_all_datasets

bool

If True, all datasets will be selected by default. Default is False.

allowed_project_types

Optional[List[ProjectType]]

A list of project types that are allowed to be selected. Default is None.

flat

bool

If True, selecting a parent dataset will not select its children. Default is False.

always_open

bool

If True, the tree will be opened when the widget is initialized.

team_is_selectable

bool

If True, the team can be selected. Default is True.

workspace_is_selectable

bool

If True, the workspace can be selected. Default is True.

append_to_body

bool

If True, the widget will be appended to the body. If False, it will be prepended.

widget_id

str

An optional ID for the widget.

default_id

Determine the default_id of the dataset to be selected when the widget is initialized. NOTE: You must provide the project_id to use this parameter.

type: int

default value: None

Initialize the widget with the default_id and project_id:

default_id

project_id

Determine the project_id to be displayed in the widget.

type: int

default value: None

Initialize the widget with the project_id:

project_id

multiselect

If True, multiple datasets can be selected. Default is False.

type: bool

default value: False

Initialize the widget with multiple selection:

multiselect

compact

If True, the widget will be displayed in compact mode without team, workspace, and project selection. Default is False.

type: bool

default value: False

Initialize the widget in compact mode:

compact

select_all_datasets

If True, all datasets will be selected by default. Default is False. NOTE: This parameter is only available when multiselect is True.

type: bool

default value: False

Initialize the widget with all datasets selected:

select_all_datasets

allowed_project_types

A list of project types that are allowed to be selected. Default is None.

type: List[ProjectType]

default value: None

Initialize the widget with allowed project types:

flat

If True, selecting a parent dataset will not select its children. Default is False.

type: bool

default value: False

Initialize the widget with the flat option:

flat

always_open

If True, the tree will be opened when the widget is initialized.

type: bool

default value: False

Initialize the widget with the always open option:

always_open

team_is_selectable

If True, the team can be selected. Default is True.

type: bool

default value: True

Initialize the widget with the team selectable:

team_is_selectable

workspace_is_selectable

If True, the workspace can be selected. Default is True.

type: bool

default value: True

Initialize the widget with the workspace selectable:

workspace_is_selectable

Methods and attributes

Methods and attributes
Description

set_project_id(project_id: int)

Set the project ID to be displayed in the widget.

get_selected_project_id()

Get the selected project ID in the widget.

get_selected_ids()

Get the selected dataset IDs in the widget for multiselect mode.

get_selected_id()

Get the selected dataset ID in the widget for single select mode.

value_changed(func: Callable)

Set the callback function to be triggered when the value is changed.

set_dataset_id(dataset_id: int)

Set the dataset ID to be selected in the widget.

set_dataset_ids(dataset_ids: List[int])

Set the dataset IDs to be selected in the widget for multiselect mode.

get_selected_team_id()

Get the selected team ID in the widget.

set_team_id(team_id: int)

Set the team ID to be selected in the widget.

get_selected_workspace_id()

Get the selected workspace ID in the widget.

set_workspace_id(workspace_id: int)

Set the workspace ID to be selected in the widget.

is_all_selected()

Check if all datasets are selected.

select_all()

Select all datasets in the widget.

Mini app example

You can find this example in our GitHub repository:

supervisely-ecosystem/ui-widgets-demos/selection/022_select_dataset_tree/src/main.py

Import libraries

Init API client

First, we load environment variables with credentials and init API for communicating with Supervisely Instance:

Initialize the widget

Create an event handler for the SelectDatasetTree widget

Create app layout

Prepare a layout for the app using Card widget with the content parameter and place widget that we've just created in the Container widget.

Create an app using the layout

Create an app object with the layout parameter.

mini_app

Last updated

Was this helpful?