OneOf
Introduction
OneOf is a container widget that can hold one of several child widgets, such as Radio, Select, or Switch. Depending on the value selected by the user within these child widgets, the corresponding item will be added to the page markup. It is very convenient to quickly switch between different items without losing sight of the overall picture.
Function signature
one_of = OneOf(
conditional_widget=Select(items=animals),
widget_id=None
)
Parameters
conditional_widget
ConditionalWidget
conditional widget with preset items (Select, RadioButton, Switch)
widget_id
str
ID of the widget
conditional_widget
Conditional widget with preset items.
type: ConditionalWidget

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/layoutsnand containers/008_one_of/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare conditional widget content
You can use RadioGroup, Select or Switch widgets to set in conditional_widget parameter. In this tutorial we will use Select widget.
Prepare sample images
Prepare items for Select widget using Select.Item
Create Select widget.
Initialize OneOf widget
OneOf widgetCreate 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
Was this helpful?