Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
|
4 |
-
DROPDOWN = None
|
5 |
-
|
6 |
def update_options(selected_option):
|
7 |
-
# new_options = 'Something '+ selected_option
|
8 |
new_options = [selected_option + str(x) for x in range(1, 4)]
|
9 |
-
print(new_options)
|
10 |
-
# DROPDOWN.update(choices=new_options)
|
11 |
-
# return new_options[0] # Return current selection to persist it in the first dropdown
|
12 |
return gr.Dropdown(choices=new_options, interactive=True)
|
13 |
|
14 |
with gr.Blocks() as interface:
|
15 |
dropdown = gr.Dropdown(choices=["Anna", "Christine", "Phoebe"])
|
16 |
dropdown2 = gr.Dropdown(choices=["Anna", "Christine", "Phoebe"], allow_custom_value=True)
|
17 |
-
btn = gr.Button("Trigger!")
|
18 |
-
DROPDOWN = dropdown2
|
19 |
-
btn.click(lambda: "Phoebe", None, dropdown)
|
20 |
dropdown.change(update_options, dropdown, dropdown2)
|
21 |
-
# dropdown.change(lambda x: x, dropdown, dropdown2)
|
22 |
|
23 |
interface.launch()
|
24 |
|
|
|
1 |
import gradio as gr
|
2 |
import time
|
3 |
|
|
|
|
|
4 |
def update_options(selected_option):
|
|
|
5 |
new_options = [selected_option + str(x) for x in range(1, 4)]
|
|
|
|
|
|
|
6 |
return gr.Dropdown(choices=new_options, interactive=True)
|
7 |
|
8 |
with gr.Blocks() as interface:
|
9 |
dropdown = gr.Dropdown(choices=["Anna", "Christine", "Phoebe"])
|
10 |
dropdown2 = gr.Dropdown(choices=["Anna", "Christine", "Phoebe"], allow_custom_value=True)
|
|
|
|
|
|
|
11 |
dropdown.change(update_options, dropdown, dropdown2)
|
|
|
12 |
|
13 |
interface.launch()
|
14 |
|