harishB97 commited on
Commit
1b73f3b
·
verified ·
1 Parent(s): b6636ea

Update app.py

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