1 from tkinter import *
 2 import webbrowser
 3 
 4 master=Tk()
 5 
 6 text=Text(master,width=50,height=20)
 7 text.pack()
 8 text.insert(INSERT,'I love FishC.com!')
 9 text.tag_add('link','1.7','1.16')
10 text.tag_config('link',background='yellow',\
11                 foreground='blue',underline=True)
12 
13 def show_arrow_cursor(event):
14     text.config(cursor='arrow')
15     
16 def show_xterm_cursor(event):
17     text.config(cursor='xterm')
18     
19 def click(event):
20     webbrowser.open('http://www.fishc.com')
21     
22     
23 text.tag_bind('link','<Enter>',show_arrow_cursor)
24 text.tag_bind('link','<Leave>',show_xterm_cursor)
25 text.tag_bind('link','<Button-1>',click)
26 
27 
28 mainloop()

 

相关文章:

  • 2021-11-06
  • 2021-12-04
  • 2021-11-15
  • 2021-10-26
  • 2021-12-12
  • 2021-09-10
猜你喜欢
  • 2021-09-19
  • 2021-12-12
  • 2021-11-16
  • 2021-12-12
  • 2021-11-15
  • 2021-11-08
  • 2021-11-15
  • 2021-11-06
相关资源
相似解决方案