abidlabs/variable-outputs
0
1import gradio as gr2 3max_textboxes = 104 5def variable_outputs(k):6 k = int(k)7 return [gr.Textbox.update(visible=True)]*k + [gr.Textbox.update(visible=False)]*(max_textboxes-k)8 9with gr.Blocks() as demo:10 with gr.Row():11 with gr.Column():12 s = gr.Slider(1, max_textboxes, step=1)13 with gr.Column():14 textboxes = []15 for i in range(max_textboxes):16 t = gr.Textbox(f"Textbox {i}")17 textboxes.append(t)18 19 s.change(variable_outputs, s, textboxes)20 21demo.launch()