我正在尝试使用Tkinter创建一个简单的登录系统,我想保存E2输入,最好在按下“注册”时在控制台中打印出来,但只输出“。!entry2”,而不输出实际输入。
import sqlite3 as sql
from tkinter import *
conn = sql.connect("database.db")
c = conn.cursor()
c.execute("""CREATE TABLE IF NOT EXISTS info(username TEXT, password TEXT)""")
conn.commit()
root = Tk()
root.title("Login Screen")
root.geometry("240x100")
def getInput():
print(E2)
# --- Username/Password
L1 = Label(root, text="Username:").grid(row=0, sticky=E)
E1 = Entry(root).grid(row=0, column=1)
L2 = Label(root, text="Password:").grid(row=1, sticky=E)
E2 = Entry(root, show="*")
E2.grid(row=1, column=1)
# ---
C1 = Checkbutton(root, text="Remember me?").grid(row=3, column=1)
# --- Buttons
B1 = Button(root, text="Login").grid(row=4, column=0)
B2 = Button(root, text="Register", command=getInput).grid(row=4, column=1)
B3 = Button(root, text="Exit", command=root.destroy).grid(row=4, column=2)
# ---
root.mainloop()