ElementTag
Introduction
ElementTag widget in Supervisely is a widget that allows users to display elements tag in the UI.
Function signature
ElementTag(text="", type=None, hit=False, color="", widget_id=None)Parameters
text
str
ElementTag text
type
Literal["primary", "gray", "success", "warning", "danger", None]
ElementTag theme
hit
bool
Whether ElementTag has a highlighted border
color
str
Background color of the ElementTag
widget_id
str
ID of the widget
text
Determine ElementTag text.
type: str
el_tag = ElementTag(text="Tag example")
type
Determine ElementTag theme.
type: Literal["primary", "gray", "success", "warning", "danger", None]
default value: None
el_tag = ElementTag(text="Tag example", type="success")
hit
Determine whether ElementTag has a highlighted border.
type: bool
default value: False
el_tag = ElementTag(text="Tag example", hit=True, type="success")
color
Determine background color of the ElementTag.
type: str
default value: ""
el_tag = ElementTag(text="Tag example", color="#E414D7", type="success")
widget_id
ID of the widget
type: str
default value: None
Methods and attributes
set_text(value: str)
Set ElementTag text.
get_text()
Return ElementTag text.
set_type()
Set ElementTag type.
get_type()
Return ElementTag type.
set_hit()
Set ElementTag hit value.
get_hit()
Get hit value.
get_color()
Return ElementTag color.
set_color(value: str)
Set ElementTag color.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/text elements/008_element_tag/src/main.py
Import libraries
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, ElementTagInit 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()Initialize ElementTag widgets
ElementTag widgetsel_tag = ElementTag(text="Tag")
all_tag_types = [el_tag]
for tag_type in ["primary", "gray", "success", "warning", "danger"]:
curr_tag = ElementTag(text=f"Tag {tag_type}", type=tag_type)
all_tag_types.append(curr_tag)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.
card = Card(
"ElementTag",
content=Container(widgets=all_tag_types, direction="horizontal"),
)
layout = Container(widgets=[card])Create app using layout
Create an app object with layout parameter.
app = sly.Application(layout=layout)
Last updated
Was this helpful?