Sorry I’m a newbie. I want to make a button that can synchronize DB data. If there are 6 pieces of data from A to F in the DB, I can display 6 Textboxes on the web page, but I don’t know how to do it. I tried the following code, but it only displays the original 4 Textboxes.
import gradio as gr
from typing import List
data = ['A', 'B', 'C', 'D']
def get_db_data() -> List:
# Get some list data from DB
...
return ['A', 'B', 'C', 'D', 'E', 'F']
def variable_outputs():
global data
data = get_db_data()
textboxs_state = []
for d in data:
textboxs_state.append(gr.Textbox(label=f'{d}'))
return textboxs_state
with gr.Blocks() as demo:
textboxs_ls = []
for d in data:
textboxs_ls.append(gr.Textbox(label=f'{d}'))
btn = gr.Button(value='refresh')
btn.click(
variable_outputs,
outputs=[x for x in textboxs_ls]
)
if __name__ == "__main__":
demo.launch()