Text-鼠标点击事件

 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','',show_arrow_cursor)
24 text.tag_bind('link','',show_xterm_cursor)
25 text.tag_bind('link','',click)
26 
27 
28 mainloop()

 

转载于:https://www.cnblogs.com/themost/p/6773657.html

你可能感兴趣的:(python)