cherokee / nav.py
amber
1
777015e
raw
history blame contribute delete
965 Bytes
import gradio as gr
def handle_link_click(link):
# 这里可以定义点击链接后的处理逻辑
# 例如,可以打开一个新的浏览器窗口来访问链接
import webbrowser
webbrowser.open(link)
with gr.Blocks(
theme=gr.themes.Soft(secondary_hue=gr.themes.colors.sky,neutral_hue=gr.themes.colors.stone)
) as demo:
with gr.Row():
# 创建三个按钮,每个按钮对应一个链接
link1 = gr.Button("Tool1")
link2 = gr.Button("Tool2")
link3 = gr.Button("Translate Tool")
# 为每个按钮设置点击事件的处理函数
link1.click(fn=lambda: handle_link_click("https://nicedata.eu.org/tool-language"))
link2.click(fn=lambda: handle_link_click("https://nicedata.eu.org/"))
link3.click(fn=lambda: handle_link_click("https://nicedata.eu.org/tool2"))
if __name__ == "__main__":
demo.launch(server_name="localhost", server_port=5008, share=True)