SelectClass
Introduction
SelectDataset widget is a dropdown menu that allows users to select a dataset or multiple datasets from a list of available datasets in the current project. It displays the name of each dataset in the list.
Function signature
SelectDataset(
default_id=None,
project_id=None,
multiselect=False,
compact=False,
show_label=True,
size=None,
disabled=False,
widget_id=None,
select_all_datasets = False,
allowed_project_types = [],
)
Parameters
default_id
int
Dataset ID
project_id
int
Project ID
multiselect
bool
Allow to select all datasets in current project
compact
bool
Show only dataset select
show_label
bool
Show label
size
Literal["large", "small", "mini", None]
Selector size
disabled
bool
Disable dataset select
widget_id
str
ID of the widget
select_all_datasets
bool
Select all datasets
allowed_project_types
List[ProjectType]
List of allowed project types
default_id
Determine Dataset will be selected by default.
type: int
default value: None
project_id
Determine Project will be selected by default.
type: int
default value: None
multiselect
Allow to select multiple datasets in current project.
type: bool
default value: false

compact
Show only Dataset select.
type: bool
default value: false

show_label
Determine show text Dataset on widget or not, work only if compact is True.
type: bool
default value: True

size
Size of input.
type: Literal["large", "small", "mini", None]
default value: None

disabled
Determine Dataset select ability.
type: bool
default value: false

select_all_datasets
Select all datasets in current project. Work only if multiselect is True.
type: bool
default value: false
allowed_project_types
List of allowed project types.
type: List[ProjectType]
default value: None
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
get_selected_id()
Return selected dataset ID, if multiselect is True raise ValueError.
get_selected_ids()
Return selected dataset IDs, if multiselect is False raise ValueError.
get_selected_project_id()
Return id of selected Project, if compact is False.
set_project_id()
Set current project id.
disable()
Set disabled attribute == True.
enable()
Set disabled attribute == False.
@value_changed
Decorator functions is handled when selected dataset ID is changed.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/selection/005_select_dataset/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare project_id and dataset_id
project_id and dataset_idInitialize SelectDataset widget
SelectDataset widgetCreate app layout
Prepare a layout for app using Card widget with the content parameter and place widget that we've just created in the Container widget.
Create app using layout
Create an app object with layout parameter.
Last updated
Was this helpful?