Cascader
Introduction
Cascader
is a dropdown list with hierarchical options.
Function signature
Example of input data we will use.
Parameters
items
List[Cascader.Item]
Input Cascader
data
filterable
bool
Whether the options can be searched
placeholder
str
Input placeholder
size
Literal["large", "small", "mini", None]
Size of input
expand_trigger
Literal["click", "hover"]
Trigger mode of expanding current item
clearable
bool
Whether selected value can be cleared
show_all_levels
bool
Whether to display all levels of the selected value in the input
change_on_select
bool
Whether selecting an option of any level is permitted
selected_options
List[str]
Current selected option
widget_id
str
ID of the widget
items
Determine input Cascader
data.
type: List[Cascader.Item]
default value: None
filterable
Determine whether the options can be searched.
type: bool
default value: False
placeholder
Determine input placeholder.
type: str
default value: select
size
Determine size of input.
type: Literal["large", "small", "mini", None]
default value: None
expand_trigger
Trigger mode of expanding current item.
type: Literal["click", "hover"]
default value: "click"
clearable
Determine whether selected value can be cleared.
type: bool
default value: False
show_all_levels
Determine whether to display all levels of the selected value in the input.
type: bool
default value: True
change_on_select
Determine whether selecting an option of any level is permitted.
type: bool
default value: False
selected_options
Determine current selected option.
type: List[str]
default value: None
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
get_value()
Return Cascader
selected value.
set_value(value: List[str])
Set Cascader
selected value.
get_items()
Return Cascader
items.
get_item()
Return Cascader.Item
item.
set_items(value: List[Cascader.Item])
Set Cascader
items.
add_items(value: List[Cascader.Item])
Add items in Cascader
.
expand_to_hover()
Set expand_trigger
to hover
mode.
expand_to_click()
Set expand_trigger
to click
mode.
@value_changed
Decorator function to handle selected value change.
Mini App Example
You can find this example in our Github repository:
supervisely-ecosystem/ui-widgets-demos/selection/015_cascader/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare items for cascader
Initialize Cascader
and Text
widgets
Cascader
and Text
widgetsCreate app layout
Prepare a layout for app using Card
widget with the content
parameter.
Create app using layout
Create an app object with layout parameter.
Add functions to control widgets from python code
Last updated