Rahul8827 commited on
Commit
5c16a9a
1 Parent(s): e3e6b7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -16
app.py CHANGED
@@ -1,22 +1,11 @@
1
  import gradio as gr
2
 
3
- options = {
4
- "A1": ["aa1", "aa11", "aa111"],
5
- "A2": ["aa2", "aa22", "aa222"],
6
- "A3": []
7
- }
8
 
9
- def greet(option1, option2):
10
- return f"Selected Option 1: {option1}\nSelected Option 2: {option2}"
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
- def update_options(option1):
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()