ipywidgets dropdown widgets: How to populate nested widgets based on selected dropdown option on onchange event?

I am trying to build a widget where I am parsing data from json and populating the tools, base form could contain simple input fields and a drop-down menu option. I want to add nested widgets based on the users choice for example as given below if the user wants an advanced parameter and select the "Full Parameter" option it should populate nested widgets (widget generated based on user input i.e. selected option)

from IPython.display import display
from ipywidgets import Dropdown

def dropdown_eventhandler(change):
    print(change.new)

option_list = ("Full Perameter", "Default Perameter")
dropdown = Dropdown(description="Choose one:", options=option_list)
dropdown.observe(dropdown_eventhandler, names='value')
display(dropdown)

I tried several things but, it dint work. I tried to invoke the underlying widget by providing conditional parameters on the callback function.

Please suggest how to solve this problem. thanks



Read more here: https://stackoverflow.com/questions/67927358/ipywidgets-dropdown-widgets-how-to-populate-nested-widgets-based-on-selected-dr

Content Attribution

This content was originally published by jax at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: