pythonGUI编程打开默认浏览器

代码:

from tkinter import *
import webbrowser

root = Tk()

text = Text(root,width=30,height = 5)
text.pack()

text.insert(INSERT, "百度一下,你就知道")

text.tag_add("link","1.0","1.4")
text.tag_config("link", foreground="blue", underline = True)

def click(event):
    webbrowser.open("http://www.baidu.com")

text.tag_bind("link","<Button-1>",click)

mainloop()

运行图:

 

posted @ 2017-08-05 15:03  胡卫雄  阅读(1391)  评论(0编辑  收藏  举报