For the complete documentation index, see llms.txt. This page is also available as Markdown.

SelectClass

Introduction

SelectClass widget in Supervisely is a dropdown menu that allows users to select object classes from a predefined list of ObjClass objects and also create new classes on the fly. It supports features like filtering and multiple selection. This widget is commonly used in applications that need to work with annotation classes, such as filtering objects, class mapping, or configuring model training parameters.

The SelectClass widget includes event handlers for tracking class selection changes and new class creation events.

Function signature

SelectClass(
    classes=[],
    filterable=True,
    placeholder="Select class",
    show_add_new_class=True,
    size=None,
    multiple=False,
    widget_id=None,
)

Parameters

Parameters
Type
Description

classes

Union[List[ObjClass], ObjClassCollection]

List of ObjClass objects or ObjClassCollection.

filterable

Optional[bool]

Enable search/filter functionality in dropdown.

placeholder

Optional[str]

Placeholder text when no class is selected.

show_add_new_class

Optional[bool]

Whether to show button for adding new classes.

size

Optional[Literal["large", "small", "mini"]]

Size of the select dropdown.

multiple

bool

Whether multiple selection is enabled.

widget_id

Optional[str]

Unique widget identifier.

classes

Initial list of ObjClass instances.

type: Union[List[ObjClass], ObjClassCollection]

default value: []

filterable

Enable or disable filtering/searching functionality in the dropdown.

type: Optional[bool]

default value: True

placeholder

Set placeholder text shown when no class is selected.

type: Optional[str]

default value: "Select class"

multiple

Enable multiple class selection.

type: bool

default value: False

show_add_new_class

Show or hide the "Add New Class" button that allows users to create new classes directly from the widget.

type: Optional[bool]

default value: True

size

Set the size of the widget.

type: Optional[Literal["large", "small", "mini"]]

default value: None

widget_id

Unique widget identifier.

type: Optional[str]

default value: None

Methods and attributes

Attributes and Methods
Description

get_selected_class()

Get the currently selected ObjClass object(s).

get_value()

Get the currently selected class name(s).

set_value()

Sets the selected class by name or list of names.

get_all_classes()

Returns a copy of all available classes.

set()

Updates the list of available classes and refreshes the widget.

@value_changed

Decorator for value change event.

@class_created

Decorator for new class creation event.

Mini App Example

You can find this example in our GitHub repository:

ui-widgets-demos/selection/026_select_class/src/main.py

Import libraries

Init API client

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

Create object classes

Initialize SelectClass widget

Create 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.

Handle class selection changes

Handle new class creation

Last updated