from sprites import Screen,Text,TK
screen = Screen()
tt = Text(100,200, height=10, font=("Arial", 20))
tt.insert(TK.INSERT, '欢迎光临微信公众号“异编程”\nPython是条蟒蛇')
# 为不同区域的文字设定样式
tt.tag_add("a", "1.0", "1.2")
tt.tag_add("b", "2.0", "2.6")
tt.tag_config("a", background = "yellow", foreground = "blue")
tt.tag_config("b", background = "black", foreground = "green")
screen.mainloop()
|