1、Text的基本属性
#-*- encoding=utf-8 -*-
importtkinterfrom tkinter import *
if __name__ == '__main__':
win= tkinter.Tk() #窗口
win.title('南风丶轻语') #标题
screenwidth = win.winfo_screenwidth() #屏幕宽度
screenheight = win.winfo_screenheight() #屏幕高度
width = 500height= 300x= int((screenwidth - width) / 2)
y= int((screenheight - height) / 2)
win.geometry('{}x{}+{}+{}'.format(width, height, x, y)) #大小以及位置
text=Text(
master=win, #父容器
bg='pink', #背景颜色
fg='red', #文本颜色
relief='sunken', #边框的3D样式 flat、sunken、raised、groove、ridge、solid。
bd=3, #边框的大小
height=3, #高度
width=20, #宽度
padx=1, #内间距,字体与边框的X距离
pady=1, #内间距,字体与边框的Y距离
state='normal', #设置状态 normal、active、 disabled
cursor='arrow', #鼠标移动时样式 arrow, circle, cross, plus...
font=('黑体', 20), #字体
wrap='char', #字数够width后是否换行 char, none, word
)
text.pack()
win.mainloop()
备注:
①支持的字体(通过tkinter.font.families获取)https://www.cnblogs.com/rainbow-tan/p/14043822.html/
②鼠标样式选项
"arrow", "circle", "clock", "cross", "dotbox", "exchange", "fleur", "heart", "man", "mouse", "pirate", "plus","shuttle", "sizing", "spider"