Path: blob/main/examples/reference/widgets/NestedSelect.ipynb
3220 views
Discover more on using widgets to add interactivity to your applications in the how-to guides on interactivity. Alternatively, learn how to set up callbacks and (JS-)links between parameters or how to use them as part of declarative UIs with Param.
Parameters:
For details on other options for customizing the component see the layout and styling how-to guides.
Core
options(dict | callable): The options to select from. The options may be nested dictionaries, lists, or callables that return those types. If callables are used, the callables must acceptlevelandvaluekeyword arguments, wherelevelis the level that updated andvalueis a dictionary of the current values, containing keys up to the level that was updated.value(dict): The value from all the Select widgets; the keys are the levels names. If no levels names are specified, the keys are the levels indices.layout(ListPanel | dict): The layout type of the widgets. If a dictionary, a "type" key can be provided, to specify the layout type of the widgets, and any additional keyword arguments will be used to instantiate the layout.levels(list): Either a list of strings or a list of dictionaries. If a list of strings, the strings are used as the names of the levels. If a list of dictionaries, each dictionary may have a "name" key, which is used as the name of the level, a "type" key, which is used as the type of widget, and any corresponding widget keyword arguments; otherwise, will inherit layoutable keyword arguments from theNestedSelectitself, e.g. width, height, and sizing_mode. Must be specified if options is callable. Must be specified if options is callable.
Display
disabled(boolean): Whether the widget is editablename(str): The title of the widget
Like most other widgets, NestedSelect has a value parameter that can be accessed or set:
A different layout type can be provided to the NestedSelect to change the layout of the widgets.
If a dict is provided, a "type" key can be provided, to specify the layout type of the widgets, and any additional keyword arguments will be used to instantiate the layout.
If levels names are not set, the value is keyed off the level index.
You can also define the default value by providing a dict.
Not all keys of the value need to be specified, and the keys can be specified in any order.
An incomplete definition of options can also be used. The corresponding subsequent widgets will be hidden.
The value for the hidden widgets will be None.
Alternatively, options can be a callable. Its nested levels too: e.g. options={"Daily": list_options, "Monthly": list_options}.
If callables are used, the callables must accept level and value keyword arguments, where level is the level that updated and value is a dictionary of the current values, containing keys up to the level that was updated.
Note, the callable can vary across options, and levels must be provided if any of the options is callable.
This is useful if you are trying to use options from a hosted source.
Using pn.cache here can help improve user experience and reduce the risk of rate limits.
levels also accepts a list of dicts, where each dict contains the type of widget and its corresponding kwargs.