美文网首页
Python3 Tkinter-Entry

Python3 Tkinter-Entry

作者: zmqqq | 来源:发表于2019-03-17 17:10 被阅读0次

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

      本文链接:https://www.haomeiwen.com/subject/nxbumqtx.html