1. # 首先需要导入webbrowser模块
    2. import webbrowser
    3. # 建立窗口window
    4. window = tk.Tk()
    5. # 给窗口的可视化起名字
    6. window.title('label超链接')
    7. # 设置窗口的居中显示
    8. screenwidth = window.winfo_screenwidth()
    9. screenheight = window.winfo_screenheight()
    10. width = 700
    11. height = 150
    12. size = "%dx%d+%d+%d" % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
    13. # 设定窗口的大小(长 * 宽)
    14. window.geometry(size)
    15. # 设置label标签
    16. link = tk.Label(window, text='点击购买高级版本: www.baidu.com', font=('Arial', 10))
    17. link.place(x=20, y=130)
    18. # 此处必须注意,绑定的事件函数中必须要包含event参数
    19. def open_url(event):
    20. webbrowser.open("http://www.baidu.com", new=0)
    21. # 绑定label单击时间
    22. link.bind("<Button-1>", open_url)