Switch
Last updated
Last updated
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.
switched
bool
Determine Switch
is ON or OFF
width
int
Width of Switch
on_text
str
Text displayed when Switch
in ON state
off_text
str
Text displayed when Switch
in OFF state
on_color
str
Background color when Switch
in ON state
off_color
str
Background color when Switch
in OFF state
on_content
Widget
Determine active Widget
when Switch
is in ON state
off_content
Widget
Determine active Widget
when Switch
is in OFF state
widget_id
str
ID of the widget
Determine Switch
is ON or OFF.
type: bool
default value: false
Determine Switch
width.
type: int
default value: 58
Determine text displayed when Switch
in ON state.
type: str
default value: ON
Determine text displayed when Switch
in OFF state.
type: str
default value: OFF
Determine background color when Switch
in ON state.
type: str
default value: None
Determine background color when Switch
in OFF state.
type: str
default value: None
Determine active Widget
when Switch
in ON state.
type: Widget
default value: None
Determine active Widget
when Switch
in OFF state.
type: Widget
default value: None
ID of the widget.
type: str
default value: None
is_switched()
Check Switch
state.
on()
Set Switch
in ON state.
off()
Set Switch
in OFF state.
get_width()
Return Switch
width.
get_on_text()
Return Switch
ON text.
set_on_text()
Set Switch
ON text.
get_off_text()
Return Switch
OFF text.
set_off_text(value: str)
Set Switch
OFF text.
get_on_color()
Return Switch
ON color.
set_on_color(value: str)
Set Switch
ON color.
get_off_color()
Return Switch
OFF color.
set_off_color(value: str)
Set Switch
OFF color.
@value_changed
Decorator function is handled when Switch
value is change.
You can find this example in our Github repository:
ui-widgets-demos/controls/004_switch/src/main.py
Switch
widgetOneOf
widget to switch between Cards
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 an app object with layout parameter.