mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-21 02:19:59 +08:00
9b42ba8f10
* changes * changes * revert changes * changes * add changeset * notebooks script * changes * changes --------- Co-authored-by: Ali Abid <aliabid94@gmail.com> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Ali Abdalla <ali.si3luwa@gmail.com>
37 lines
855 B
Python
37 lines
855 B
Python
import gradio as gr
|
|
|
|
with gr.Blocks() as demo:
|
|
text_count = gr.Slider(1, 5, step=1, label="Textbox Count")
|
|
|
|
@gr.render(inputs=text_count)
|
|
def render_count(count):
|
|
boxes = []
|
|
for i in range(count):
|
|
box = gr.Textbox(key=i, label=f"Box {i}")
|
|
boxes.append(box)
|
|
|
|
def merge(*args):
|
|
return " ".join(args)
|
|
|
|
merge_btn.click(merge, boxes, output)
|
|
|
|
def clear():
|
|
return [""] * count
|
|
|
|
clear_btn.click(clear, None, boxes)
|
|
|
|
def countup():
|
|
return [i for i in range(count)]
|
|
|
|
count_btn.click(countup, None, boxes, queue=False)
|
|
|
|
with gr.Row():
|
|
merge_btn = gr.Button("Merge")
|
|
clear_btn = gr.Button("Clear")
|
|
count_btn = gr.Button("Count")
|
|
|
|
output = gr.Textbox()
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch()
|