ClassesMapping
Introduction
Classes Mapping widget allows to rename given object classes with new names. It can be useful when you want to rename classes in your project.
Function signature
classes_mapping = ClassesMapping(
classes=obj_classes,
empty_notification=None,
widget_id=None
)Parameters
classes
Union[List[ObjClass], ObjClassCollection]
Supervisely object class collection or list of object classes
empty_notification
NotificationBox
Notification that will be displayed when there are no classes in widget
widget_id
str
ID of the widget
classes
List of ObjClass objects or Supervisely object class collection (ObjClassCollection).
type: Union[List[ObjClass], ObjClassCollection]
empty_notification
Notification that will be displayed when there are no classes in the widget.
type: NotificationBox
default None
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
set()
Set classes to widget.
get_classes()
Return list of all classes.
get_mapping()
Return edited classes mapping, if there were any changes.
ignore()
Ignore classes by indexes.
set_default()
Revert changes.
set_mapping()
Set new classes mapping.
select_all()
Select all classes.
deselect_all()
Deselect all classes.
select()
Select classes by ObjClass.
@selection_changed
Callback triggers when selection is changed.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/input/009_classes_mapping/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Create list of object classes
Initialize ClassesMapping widget, NotificationBox widget for custom notification
ClassesMapping widget, NotificationBox widget for custom notificationCreate Text widget for displaying changes and Button widget for saving changes
Text widget for displaying changes and Button widget for saving changesCreate app layout
Prepare a layout for the app using the Card widget with the content parameter and place the widget that we've just created into the Container widget.
Create the app using the layout
Create an app object with the layout parameter.
Add functions to control widgets from the python code
Last updated
Was this helpful?