import gradio as gr import datetime def update_content(): current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") return f"界面已更新,当前时间: {current_time}" with gr.Blocks() as demo: gr.HTML("""

动态更新界面示例

点击按钮来更新这里的内容
""") output = gr.Textbox(label="更新内容") update_button = gr.Button("更新", visible=False) update_button.click(fn=update_content, inputs=[], outputs=[output]) gr.HTML(""" """) demo.launch()