Dynamiradio / app.py
rianders's picture
Update app.py
f0d419c
raw
history blame contribute delete
661 Bytes
import gradio as gr
from pprint import pprint
def update_list(current_list):
if not current_list:
current_list = []
new_item = f"Item {len(current_list) + 1}"
current_list.append(new_item)
return current_list
with gr.Blocks() as demo:
with gr.Row():
button = gr.Button("Add Item")
radio = gr.Radio(label="Items List", choices=[])
state = gr.State([]) # Initialize state
# When button is clicked, update the list
button.click(fn=update_list, inputs=state, outputs=state)
# Update the radio options when the state changes
state.change(fn=lambda x: x, inputs=state, outputs=radio)
demo.launch()