rianders commited on
Commit
95eeeb2
·
1 Parent(s): bc2b28f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def update_list(current_list, _):
4
+ if not current_list:
5
+ current_list = []
6
+ new_item = f"Item {len(current_list) + 1}" # Example of dynamically generating new items
7
+ current_list.append(new_item)
8
+ return current_list
9
+
10
+ with gr.Blocks() as demo:
11
+ with gr.Row():
12
+ button = gr.Button("Add Item")
13
+ radio = gr.Radio(label="Items List")
14
+
15
+ state = gr.State([]) # Initialize state
16
+
17
+ # When button is clicked, update list
18
+ button.click(fn=update_list, inputs=[state, button], outputs=state)
19
+ state.change(fn=lambda x: x, inputs=state, outputs=radio)
20
+
21
+ demo.launch()