A. 最终效果
B. 示例代码
import gradio as gr
import gradio as gr
with gr.Blocks() as demo:
input_text = gr.Textbox()
@gr.render(inputs=input_text)
def show_split(text):
if len(text) == 0:
gr.Markdown("## No Input Provided")
else:
# for letter in text:
for letter in range(int(text)):
with gr.Row():
text = gr.Textbox(letter)
btn = gr.Button("Clear")
btn.click(lambda: gr.Textbox(value=""), None, text)
demo.launch()
C. 参考文献
- Gradio 渲染文档 — Gradio render Docs
- 使用 Render Decorator 的动态应用程序 — Dynamic Apps With Render Decorator