InputTagList

Introduction

InputTagList widget in Supervisely is a user interface element that allows users to work with multiple tag labels simultaneously. Unlike the single InputTag widget, InputTagList enables bulk operations on tag collections, making it easier to manage multiple tags at once. It uses a list of TagMeta objects and provides convenient methods for selecting, deselecting, and manipulating multiple tags. This widget is particularly useful for applications that need to handle multiple tag operations efficiently.

Function signature

InputTagList(
    tag_metas,
    max_width=300,
    max_height=50,
    multiple=False,
    widget_id=None,
)

Parameters

Parameters
Type
Description

tag_metas

Union[List[TagMeta], TagMetaCollection]

List of TagMeta objects from which Tags will be managed

max_width

int

Max tag field width

max_height

int

Max tag field height

multiple

bool

If set False, only one tag can be selected at a time, otherwise can select several tags (multi-select).

widget_id

str

ID of the widget

tag_metas

Determine list of TagMeta objects from which Tags will be managed. Supports all possible Tag types: any_number, any_string, one_of_string, none.

type: Union[List[TagMeta], TagMetaCollection]

max_width

Determine max tag field width.

type: int

default value: 300

max_height

Determine max tag field height.

type: int

default value: 50

multiple

If set False, only one tag can be selected at a time, otherwise can select several tags (multi-select).

type: bool

default value: False

widget_id

ID of the widget.

type: str

default value: None

Methods and attributes

Attributes and Methods
Description

select_all()

Select all available tags in the list.

deselect_all()

Deselect all tags in the list.

select(tag_names: List[str])

Select specific tags by their names.

get_selected_tags()

Get list of currently selected tags with their values.

get_selected_tag_metas()

Get list of TagMeta objects for currently selected tags.

set_values(values: Dict[str, Any])

Set values for tags by tag name.

@selection_changed

Decorator function is handled when tag selection is changed.

Mini App Example

You can find this example in our Github repository:

ui-widgets-demos/misc/input_tag_list/src/main.py

Import libraries

Init API client

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

Create different types of tag metas for demonstration

Initialize InputTagList widget

Initialize control buttons and text widget

Create app layout

Prepare a layout for app using Card widget with the content parameter and place widgets in containers.

Create app using layout

Create an app object with layout parameter.

Handle button clicks and selection changes

Use decorators to handle button clicks and tag selection changes:

Last updated

Was this helpful?