Text
Introduction
Text widget in Supervisely is used to display text with different styles, such as "text", "info", "success", "warning", or "error". Content and style of the text can be easily changed drom code. The Text widget is useful for presenting informative messages or status updates to users, and can be combined with other widgets to create more complex interfaces.
Function signature
Text(
text=None,
status="text",
widget_id=None,
)
Parameters
text
str
Determine displayed text
status
Literal["text", "info", "success", "warning", "error"]
Message status
color
str
Text color in hex format
font_size
int
Size of the font in pixels
widget_id
str
ID of the widget
text
Determine displayed text.
type: str
default value: None
status
Text status.
type: str
default value: text

color
Text color in hex format.
type: str
default value: None
font_size
Size of the font in pixels.
type: int
default value: 14
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
text
Get or set text property.
status
Get or set status property.
color
Get or set color property.
set()
Set text value and status to widget.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/text elements/001_text/src/main.py
Import libraries
Init API client
Init API for communicating with Supervisely Instance. First, we load environment variables with credentials:
Initialize five Button widgets for each type of text message: text, info, success, warning, error
Button widgets for each type of text message: text, info, success, warning, errorInitialize Container widget
Container widgetCreate Container widget for all buttons.
Initialize Text widget with text and status
Text widget with text and statusCreate app layout
Prepare a layout for app using Card widget with the content parameter and place 2 widgets that we've just created in the Container widget. Place order in the Container is important, we want the message text to be displayed below the buttons.
Create app using layout
Create an app object with layout parameter.
Our app layout is ready.
Start text status change with button click
Use the decorator as shown below to handle button click. Text will be updating it status after pressing corresponding button.

Last updated
Was this helpful?