Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
max_textboxes = 10
|
4 |
+
|
5 |
+
def variable_outputs(k):
|
6 |
+
k = int(k)
|
7 |
+
return [gr.Textbox(visible=True)]*k + [gr.Textbox(visible=False)]*(max_textboxes-k)
|
8 |
+
|
9 |
+
with gr.Blocks() as demo:
|
10 |
+
s = gr.Slider(1, max_textboxes, value=max_textboxes, step=1, label="How many textboxes to show:")
|
11 |
+
textboxes = []
|
12 |
+
for i in range(max_textboxes):
|
13 |
+
t = gr.Textbox(f"Textbox {i}")
|
14 |
+
textboxes.append(t)
|
15 |
+
|
16 |
+
s.change(variable_outputs, s, textboxes)
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
demo.launch()
|