Classes List Selector widget allows users to view a list of object classes and change it dynamically using widget methods. This widget can be used for visualizing and selecting classes in Supervisely.
Notification that will be displayed when there are no classes in widget
type:NotificationBox
defaultNone
notification_box = NotificationBox(title="No classes", description="Provide classes to the widget.")
classes_list_selector = ClassesListSelector(
multiple=True,
empty_notification=notification_box
)
widget_id
ID of the widget.
type:str
default value:None
Methods and attributes
Attributes and Methods
Description
set()
Set classes to widget.
get_selected_classes()
Return list of selected classes.
select_all()
Select all classes.
deselect_all()
Deselect all classes.
select()
Select classes by names.
deselect()
Deselect classes by names.
set_multiple()
Set multiple flag.
get_all_classes()
Return list of all classes.
@selection_changed
Callback triggers when selection is changed.
Mini App Example
You can find this example in our Github repository:
Import libraries
import os
import supervisely as sly
from supervisely.app.widgets import Card, Container, ClassesListSelector, NotificationBox, Text
from dotenv import load_dotenv
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()