tilents
test1
5cfdf88
raw
history blame contribute delete
654 Bytes
import gradio as gr
# 定义处理函数,根据用户输入生成不同的按钮
def dynamic_buttons(user_input):
if user_input == "A":
button_html = "<button onclick='alert(\"按钮A被点击了!\")'>按钮A</button>"
elif user_input == "B":
button_html = "<button onclick='alert(\"按钮B被点击了!\")'>按钮B</button>"
else:
button_html = "<button onclick='alert(\"未知按钮被点击了!\")'>未知按钮</button>"
return button_html
# 创建 Gradio 接口,输入是文本,输出是HTML
iface = gr.Interface(fn=dynamic_buttons, inputs="text", outputs="html")
# 启动界面
iface.launch()