Switch
Introduction
Switch
widget in Supervisely is a user interface element that allows users to toggle between two states, such as on/off or true/false. With the Switch widget, users can easily turn on or off a specific feature or setting. The Switch widget is useful for creating project dashboards that require users to toggle specific options quickly and easily. Users can customize the appearance and behavior of the Switch widget to match their project requirements, making it a flexible tool for creating user interfaces in Supervisely apps. Overall, the Switch widget is a simple yet effective tool for improving the usability and functionality of Supervisely apps.
Function signature
Parameters
Parameters | Type | Description |
---|---|---|
|
| Determine |
|
| Width of |
|
| Text displayed when |
|
| Text displayed when |
|
| Background color when |
|
| Background color when |
|
| Determine active |
|
| Determine active |
|
| ID of the widget |
switched
Determine Switch
is ON or OFF.
type: bool
default value: false
width
Determine Switch
width.
type: int
default value: 58
on_text
Determine text displayed when Switch
in ON state.
type: str
default value: ON
off_text
Determine text displayed when Switch
in OFF state.
type: str
default value: OFF
on_color
Determine background color when Switch
in ON state.
type: str
default value: None
off_color
Determine background color when Switch
in OFF state.
type: str
default value: None
on_content
Determine active Widget
when Switch
in ON state.
type: Widget
default value: None
off_content
Determine active Widget
when Switch
in OFF state.
type: Widget
default value: None
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
Attributes and Methods | Description |
---|---|
| Check |
| Set |
| Set |
| Return |
| Return |
| Set |
| Return |
| Set |
| Return |
| Set |
| Return |
| Set |
| Decorator function is handled when |
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/controls/004_switch/src/main.py
Import libraries
Initialize Switch
widget
Switch
widgetInitialize OneOf
widget to switch between Cards
OneOf
widget to switch between Cards
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.
Create app using layout
Create an app object with layout parameter.
Last updated