1.创建
from tkinter import *
root=Tk()
t1=Entry(root)
t1.pack()
root.mainloop()
![](https://img.haomeiwen.com/i16468855/c1e5b2247cf98d27.png)
2.绑定变量
from tkinter import *
root=Tk()
e=StringVar()
t1=Entry(root,textvariable=e)
e.set('input your text here')
t1.pack()
root.mainloop()
![](https://img.haomeiwen.com/i16468855/49bb98283393887d.png)
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
![](https://img.haomeiwen.com/i16468855/a388c6e4f234ad5f.png)
4.设置为密码框
from tkinter import *
root=Tk()
e=StringVar()
t1=Entry(root,textvariable=e,show='*')
e.set('input your text here')
t1.pack()
root.mainloop()
![](https://img.haomeiwen.com/i16468855/703e3c910536b60f.png)
5.属性
fg/bg/relief/width/height/justify/state同Button
网友评论