Python精灵模块的Text指令

所有命令 单独命令 屏幕命令 角色命令

单独命令 >> Python精灵模块的Text指令

简介:这是多行文本框,可以为不同区域的文字设定不同的风格。
例子:
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()


writed by lixingqiu 关注"异编程"微信公众号,获取更多关于Python精灵模块的咨讯: