Python3 Tkinter-Entry

1.创建

from tkinter import *

root=Tk()

t1=Entry(root)
t1.pack()

root.mainloop()
图片.png

2.绑定变量

from tkinter import *

root=Tk()

e=StringVar()

t1=Entry(root,textvariable=e)
e.set('input your text here')

t1.pack()

root.mainloop()
图片.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
图片.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()
图片.png

5.属性

fg/bg/relief/width/height/justify/state同Button

你可能感兴趣的:(Python3 Tkinter-Entry)