# def words(): # sentence = "A test of Gradio" # words = sentence.split() # update_show = [gr.Button.update(visible=True, value=w) for w in words] # update_hide = [gr.Button.update(visible=False, value="") for _ in range(10-len(words))] # return update_show + update_hide # import gradio as gr # def words(): # sentence = "A test of Gradio" # words = sentence.split() # update_show = [gr.Button(visible=True, value=w) for w in words] # update_hide = [gr.Button(visible=False, value="") for _ in range(10-len(words))] # return update_show + update_hide # btn_list = [] # with gr.Blocks() as demo: # with gr.Tab(): # for i in range(10): # btn = gr.Button(visible=False) # btn_list.append(btn) # b = gr.Button("Run") # b.click(words, None, btn_list) # demo.launch() import gradio as gr def words(): sentence = "A test of Gradio" words = sentence.split() update_show = [gr.Textbox(visible=True, value=w,interactive=True) for w in words] update_hide = [gr.Textbox(visible=False, value="",interactive=True) for _ in range(10-len(words))] return update_show + update_hide def get_text_content(*btn_list): # make all the input as a list # merge_list # rtn =[w.value for w in btn_list if w.visible] rtn =' '.join([w for w in btn_list ]) print(rtn) return rtn btn_list = [] with gr.Blocks() as demo: with gr.Row(): for i in range(10): btn = gr.Textbox(visible=False) btn_list.append(btn) b = gr.Button("Run") b.click(words, None, btn_list) b = gr.Button("Get Text Content") output = gr.Textbox() b.click(get_text_content, btn_list, output) demo.launch(debug=True)