Update app.py
Browse files
app.py
CHANGED
|
@@ -1,22 +1,11 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
"A2": ["aa2", "aa22", "aa222"],
|
| 6 |
-
"A3": []
|
| 7 |
-
}
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
option1_dropdown = gr.inputs.Dropdown(choices=["A1", "A2", "A3"], label="Dropdown 1")
|
| 13 |
-
option2_dropdown = gr.inputs.Dropdown(choices=[], label="Dropdown 2") # Initial empty choices
|
| 14 |
|
| 15 |
output_text = gr.outputs.Textbox()
|
| 16 |
|
| 17 |
-
|
| 18 |
-
option2_dropdown.choices = options.get(option1, []) # Update choices for option2 based on option1
|
| 19 |
-
|
| 20 |
-
gr.Interface(fn=greet, inputs=[option1_dropdown, option2_dropdown], outputs=output_text,
|
| 21 |
-
examples=[["A1", "aa1"], ["A2", "aa2"]], title="Dynamic Dropdowns",
|
| 22 |
-
preprocessing_hooks=[update_options]).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def dropdownbx(first, second):
|
| 4 |
+
return f"selected_option_1st, {first}! selected_option_2nd {second}."
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
name_dropdown = gr.inputs.Dropdown(choices=["A1", "A2", "A3"], label="first")
|
| 7 |
+
city_dropdown = gr.inputs.Dropdown(choices=["aa1", "aa11", "aa2" , "aa22"], label="second")
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
output_text = gr.outputs.Textbox()
|
| 10 |
|
| 11 |
+
gr.Interface(fn=dropdownbx, inputs=[name_dropdown, city_dropdown], outputs=output_text).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|