Introduction
SelectTagMeta
widget in Supervisely is a drop down menu that allows users to select a TagMeta
from a list of available tag metadatas. The widget can be customized with various parameters, such as the default selected tag metadata, default project ID, size, allowed types, multiple selection, label showing.
Function signature
Copy SelectTagMeta (
default = None ,
project_id = None ,
project_meta = None ,
allowed_types = None ,
multiselect = False ,
show_label = True ,
size = None ,
widget_id = None ,
)
Parameters
Parameters Type Description Determine Project
from which Tags
will be selected.
Determine ProjectMeta
from which Tags
will be selected
Determine Tags
types witch will be available to select from all Project
Tags
Allows to select multiple Tags
Literal["large", "small", "mini", None]
default
Determine Tag
will be selected by default.
type: str
default value: None
Copy select_tag_meta = SelectTagMeta (default = "rust" , project_id = project_id)
project_id
Determine Project
from which Tags
will be selected.
type: int
default value: None
Copy select_tag_meta = SelectTagMeta (project_id = project_id)
project_meta
Determine ProjectMeta
from which Tags
will be selected.
type: ProjectMeta
default value: None
Copy meta_json = api . project . get_meta (project_id)
project_meta = sly . ProjectMeta . from_json (meta_json)
select_tag_meta = SelectTagMeta (project_meta = project_meta)
allowed_types
Determine Tags
types witch will be available to select from all Project
Tags
. Possible Tag
types: any_number
, any_string
, one_of_string
, none
.
type: List[str]
default value: None
Copy from supervisely . annotation . tag_meta import TagValueType
allowed_types = [TagValueType . ANY_STRING]
select_tag_meta = SelectTagMeta (project_id = project_id, allowed_types = allowed_types)
multiselect
Allows to select multiple Tags
.
type: bool
default value: False
Copy select_tag_meta = SelectTagMeta (project_id = project_id, multiselect = True )
show_label
Determine show text Tag
on widget or not.
type: bool
default value: True
Copy select_tag_meta = SelectTagMeta (project_id = project_id, show_label = False )
size
Size of input.
type: Literal["large", "small", "mini", None]
default value: None
Copy select_tag_meta = SelectTagMeta (default = "cat" , project_id = project_id, show_label = False )
select_mini = SelectTagMeta (default = "cat" , project_id = project_id, show_label = False , size = "mini" )
select_small = SelectTagMeta (default = "cat" , project_id = project_id, show_label = False , size = "small" )
select_large = SelectTagMeta (default = "cat" , project_id = project_id, show_label = False , size = "large" )
card = Card (
title = "Select TagMeta" ,
content = Container (widgets = [select_tag_meta, select_mini, select_small, select_large]),
)
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
Attributes and Methods Description Return selected tag name. If multiselect is True
raise RuntimeError
.
Return List
with selected Tag
names. If multiselect is False
raise RuntimeError
.
get_tag_meta_by_name(name: str)
Return TagMeta
by Tag
name.
Return TagMeta
for selected Tag
.
Return List
, containing TagMeta
for selected tags.
Set Tag
with given name as selected
.
set_names(names: List[str])
Set Tags
from given list of Tag
names as selected
. If multiselect is False
raise RuntimeError
.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/selection/007_select_tag_meta/src/main.py
Import libraries
Copy import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely . app . widgets import Card , Container , SelectTagMeta
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Copy load_dotenv ( "local.env" )
load_dotenv (os.path. expanduser ( "~/supervisely.env" ))
api = sly . Api ()
Prepare Project
ID
Copy project_id = sly . env . project_id ()
Initialize SelectTagMeta
widget
Copy select_tag_meta = SelectTagMeta (default = "cat" , project_id = project_id)
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.
Copy card = Card (
title = "Select TagMeta" ,
content = select_tag_meta,
)
layout = Container (widgets = [card])
Create app using layout
Create an app object with layout parameter.
Copy app = sly . Application (layout = layout)