Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
with gr.Blocks() as demo:
|
4 |
+
text_count = gr.State(1)
|
5 |
+
add_btn = gr.Button("Add Box")
|
6 |
+
add_btn.click(lambda x: x + 1, text_count, text_count)
|
7 |
+
|
8 |
+
@gr.render(inputs=text_count)
|
9 |
+
def render_count(count):
|
10 |
+
boxes = []
|
11 |
+
for i in range(count):
|
12 |
+
box = gr.Textbox(key=i, label=f"Box {i}")
|
13 |
+
boxes.append(box)
|
14 |
+
|
15 |
+
def merge(*args):
|
16 |
+
return " ".join(args)
|
17 |
+
|
18 |
+
merge_btn.click(merge, boxes, output)
|
19 |
+
|
20 |
+
|
21 |
+
merge_btn = gr.Button("Merge")
|
22 |
+
output = gr.Textbox(label="Merged Output")
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
demo.launch()
|