1、tags用法学习
from tkinter import *
root=Tk()
text=Text(root,width=30,height=5)
text.pack()
text.insert(INSERT,“从前车马很慢,一生只爱一人”)
text.tag_add(“tag1”,“1.7”,“1.12”,“1.14”)
text.tag_config(“tag1”,background=“yellow”,foreground=“red”)
mainloop()
结果图:
颜色修改:
from tkinter import *
root=Tk()
text=Text(root,width=30,height=5)
text.pack()
text.insert(INSERT,“从前车马很慢,一生只爱一人”)
text.tag_add(“tag1”,“1.7”,“1.12”,“1.14”)
text.tag_add(“tag2”,“1.7”,“1.12”,“1.14”)
text.tag_config(“tag1”,background=“yellow”,foreground=“red”)
text.tag_config(“tag2”,foreground=“blue”)
mainloop()
(1)打开网页
text.pack()
text.insert(INSERT,“I love FishC.com!”)
text.tag_add(“link”,“1.7”,“1.16”)
text.tag_config(“link”,foreground=“blue”,underline=True)
def show_arrow_cursor(event):
text.config(cursor=“arrow”)
def show_xterm_cursor(event):<