The choices of item radio is not changed after changing category_radio, also unable to select any item_radio value
categories = {
"Fruits": ["Apple", "Banana", "Cherry"],
"Vegetables": ["Carrot", "Broccoli", "Spinach"]
}
def update_options(selected_category="Fruits"):
print(selected_category)
changed_values = categories[selected_category]
print(changed_values)
return changed_values
with gr.Blocks() as demo:
# category
category_radio = gr.Radio(choices=list(categories.keys()), label="Select a Category")
# to be updated according to category
item_radio = gr.Radio(choices=update_options(), label="Select an Item")
# change event of category
category_radio.change(fn=update_options, inputs=category_radio, outputs=item_radio)
demo.launch(debug=True)