Badge
Introduction
Badge widget in Supervisely is a versatile tool for displaying notifications or counts on elements such as buttons, text. With customizable types (number, text, or dot), visibility, the Badge can be easily used in Supervisely apps for a seamless user experience.
Function signature
Badge(
value: Union[int, str, float] = None,
widget: Optional[Widget] = None,
max: int = None,
is_dot: bool = False,
hidden: bool = False,
widget_id: str = None,
)
Parameters
value
Union[int, str, float]
Badge widget content value
widget
Optional[Widget]
Determine a widget to content in badge
max
int
Determine max value of badge content. Value type has to be a number
is_dot
bool
Specifies that badge is displayed as a dot
hidden
bool
Specifies that a badge widget is hidden
widget_id
str
ID of the widget
value
Badge widget content value
type: Union[int, str, float]
default value: None

widget
Determine a widget to content in badge
type: Optional[Widget]
default value: None

max
Determine max value of badge content. Value type has to be a number
type: int
default value: None

is_dot
Specifies that badge is displayed as a dot
type: bool
default value: False

hidden
Specifies that a badge widget is hidden
type: bool
default value: False

widget_id
ID of the widget
type: str
default value: None
Methods and attributes
set_value(value: Union[str, int, float])
Set badge value
get_value()
Get badge value
clear()
Clear badge value
hide_badge()
Hide badge on widget
show_badge()
Show badge on widget
toggle_visibility()
Toggle visibility of badge on widget
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/status-elements/006_badge/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare Button, Checkbox, Input, InputNumber widgets to contain in Badge widgets
Button, Checkbox, Input, InputNumber widgets to contain in Badge widgetsCreate Badge widgets we will use in UI for demo
Badge widgets we will use in UI for demoCreate 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.
Create app using layout
Create an app object with layout parameter.
Add functions to control widgets from code

Last updated
Was this helpful?