SelectTag widget in Supervisely is a compact dropdown menu that allows users to select tag metadata from a predefined list of TagMeta objects and create new tags on the fly. It supports features like filtering, multiple selection, and various tag value types (None, Any String, Any Number, One Of). This widget is commonly used in applications that need to work with annotation tags, such as filtering objects by tags, tag mapping, or configuring tagging workflows.
The SelectTag widget includes event handlers for tracking tag selection changes and new tag creation events.
@select_tag.value_changed
def on_tag_selected(selected_tags):
if isinstance(selected_tags, list):
tag_names = [tag.name for tag in selected_tags]
notification_box.set(
title="Tags selected",
description=f"Selected tags: {', '.join(tag_names)}",
)
else:
notification_box.set(
title="Tag selected",
description=f"Selected tag: {selected_tags.name}",
)
@select_tag.tag_created
def on_tag_created(new_tag: sly.TagMeta):
notification_box.set(
title="New tag created",
description=f"You have created a new tag: {new_tag.name} (type: {new_tag.value_type})",
)