1.创建
from tkinter import *
root=Tk()
t1=Entry(root)
t1.pack()
root.mainloop()

2.绑定变量
from tkinter import *
root=Tk()
e=StringVar()
t1=Entry(root,textvariable=e)
e.set('input your text here')
t1.pack()
root.mainloop()

3.只读
from tkinter import *
root=Tk()
e=StringVar()
t1=Entry(root,textvariable=e,state='readonly')
e.set('input your text here')
t1.pack()
root.mainloop()
readonly=disabled

4.设置为密码框
from tkinter import *
root=Tk()
e=StringVar()
t1=Entry(root,textvariable=e,show='*')
e.set('input your text here')
t1.pack()
root.mainloop()

5.属性
fg/bg/relief/width/height/justify/state同Button
网友评论