Change radio choices based on response of another radio value
The choices of item radio is not changed after changing category_radio, also unable to select any item_radio valuecategories = {
    "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)
2024-11-11T01:33:53Z
It should look like this.def update_options(selected_category="Fruits"):
    print(selected_category)
    changed_values = categories[selected_category]
    print(changed_values)
    return gr.update(choices=changed_values)