m-ric HF staff commited on
Commit
10072b9
1 Parent(s): 94d83b2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
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()