tkinter的控件Entry(python GUI )

摘要:tkinter是python GUI的标准库,本文介绍tkinter的Entry对象的使用。

00 Entry-文本框

from tkinter import *
win=Tk()
win.title('leslie-wj')
win.geometry('500x200')
name=Label(win,text='Name')
password=Label(win,text='Password')
name.grid(row=0,column=0)
password.grid(row=1,column=0)
nameE=Entry(win)
passwordE=Entry(win)
nameE.grid(row=0,column=1)
passwordE.grid(row=1,column=1)
win.mainloop()

tkinter的控件Entry(python GUI )的图1

01 background和foreground的用法

from tkinter import *
win=Tk()
win.title('leslie-wj')
win.geometry('500x200')
name=Label(win,text='Name')
password=Label(win,text='Password')
name.grid(row=0,column=0)
password.grid(row=1,column=0)
nameE=Entry(win,background='yellow')
passwordE=Entry(win,foreground='red')

nameE.grid(row=0,column=1)
passwordE.grid(row=1,column=1)
win.mainloop()

tkinter的控件Entry(python GUI )的图2

02 show的使用

from tkinter import *
win=Tk()
win.title('leslie-wj')
win.geometry('500x200')
name=Label(win,text='Name')
password=Label(win,text='Password')
name.grid(row=0,column=0)
password.grid(row=1,column=0)
nameE=Entry(win)
passwordE=Entry(win,show='*')
nameE.grid(row=0,column=1)
passwordE.grid(row=1,column=1)
win.mainloop()

tkinter的控件Entry(python GUI )的图3

03 insert的使用

from tkinter import *
win=Tk()
win.title('leslie-wj')
win.geometry('500x200')
name=Label(win,text='Name')
password=Label(win,text='Password')
name.grid(row=0,column=0)
password.grid(row=1,column=0)
nameE=Entry(win)
passwordE=Entry(win)
nameE.insert(0,'leslie')
passwordE.insert(0,1990)

nameE.grid(row=0,column=1)
passwordE.grid(row=1,column=1)
win.mainloop()

tkinter的控件Entry(python GUI )的图4

默认 最新
当前暂无评论,小编等你评论哦!
点赞 1 评论 收藏
关注