Python Tkinter save entry

 

 

 

 

from tkinter import *
ws = Tk()
ws.title("Python Guides")
ws.geometry("200x200")
name_variable = StringVar()
password_var = StringVar()
def submit():
    name = name_variable.get()
    password = password_var.get()
    print("The name is : " + name)
    print("The password is : " + password)
    name_variable.set("")
    password_var.set("")


name_label = Label(ws, text='Username', font=('calibre', 10, 'bold'))
name_entry = Entry(ws, textvariable=name_variable, font=('calibre', 10, 'normal'))
password_label = Label(ws, text='Password', font=('calibre', 10, 'bold'))
password_entry = Entry(ws, textvariable=password_var, font=('calibre', 10, 'normal'), show='*')
submit_button = Button(ws, text='Submit', command=submit)
name_label.grid(row=0, column=0)
name_entry.grid(row=0, column=1)
password_label.grid(row=1, column=0)
password_entry.grid(row=1, column=1)
submit_button.grid(row=2, column=1)

ws.mainloop()

  

 

posted @ 2021-11-17 19:20  linbo.yang  阅读(38)  评论(0编辑  收藏  举报