dummy_render / app.py
ysharma's picture
ysharma HF staff
Update app.py
ba33199 verified
raw
history blame contribute delete
863 Bytes
import gradio as gr
with gr.Blocks() as demo1:
show_box = gr.Checkbox()
@gr.render(inputs=show_box)
def render(show_box):
if show_box:
textbox = gr.Textbox()
textbox2 = gr.Textbox()
textbox.change(lambda x:x, textbox, textbox2)
else:
gr.Markdown("Hidden textbox")
#demo.launch(debug=True)
import gradio as gr
def predict(*args):
print(args)
return {"inputs": list(args)}
with gr.Blocks() as demo:
s = gr.Slider(1, 4, step=1, interactive=True)
@gr.render(inputs=s, triggers=[s.change])
def render(num):
texts = []
with gr.Row():
for i in range(num):
texts.append(gr.Textbox())
json = gr.JSON()
btn = gr.Button("RUN")
btn.click(fn=predict, inputs=texts, outputs=json)
demo.launch(debug=True)