Button
Introduction
Button
widget in Supervisely is a user interface element that allows users to create clickable buttons in the appliactions. These buttons can be customized with text, size, colors, and icons, and can be used to trigger specific actions or workflows. The Button widget is a versatile tool that can help users automate repetitive tasks or streamline their workflows, making it a valuable addition to any project dashboard.
Function signature
Parameters
Parameters | Type | Description |
---|---|---|
|
| Determine text that displayed on the button |
|
| Button type |
|
| Button size |
|
| Determine whether button is a plain button |
|
| If |
|
| Button icon, accepts an icon name of icon from Material Design Iconic Font library |
|
| Gap between icon and button text |
|
| Emit an event on click |
|
| Call JavaScript function on click |
|
| ID of the widget |
text
Determine text that will be displayed on the button.
type: str
default value: Button
button_type
Button type.
type: Literal["primary", "info", "warning", "danger", "success", "text"]
default value: "primary"
button_size
Button size.
type: Literal["mini", "small", "large", None]
default value: None
plain
Determine whether button is a plain button.
type: bool
default value: False
show_loading
Determine whether button is loading.
type: bool
default value: False
icon
Button icon, accepts an icon name of icon component. Icons can be found at zavoloklom.github.io.
Open any icon at zavoloklom.github.io and copy it's name (see example below).
type: str
default value: None
icon_gap
Gap between icon and button text.
type: int
default value: 5
emit_on_click
Emit an event on click
type: str
default value: ""
style
Specifies an inline style for an element.
type: str
default value: ""
call_on_click
Call JavaScript function on click.
type: str
default value: ""
widget_id
ID of the widget.
type: str
default value: None
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/controls/001_button/src/main.py
Init API client
Init API for communicating with Supervisely Instance. First, we load environment variables with credentials:
Initialize Button
and Text
widgets
Button
and Text
widgetsCreate app layout
Prepare a layout for app using Card
widget with the content
parameter and place 3 widgets that we've just created in the Container
widget. Place order in the Container
is important, we want buttons to be displayed above Text
widget.
Create app using layout
Create an app object with layout parameter.
Our app layout is ready. It's time to handle button clicks.
Handle button clicks
Use the decorator as shown below to handle button click. We have 2 buttons, one for adding and another one for subtracting
Last updated