我的tkinter登录屏幕应用程序有一个错误,即当我单击登录按钮时它只显示错误。
from tkinter import *
from tkinter import messagebox
login_page = Tk()
login_page.title("login_page")
login_page.geometry("250x110")
def check_pass():
if username == name and userpass == password:
print("this code works")
else :
messagebox.askretrycancel(title="Try again",message="Wrong password ")
# name and password entry
log_name = Entry(login_page)
log_name.grid(row=0, column=1, pady=15)
log_pass = Entry(login_page)
log_pass.grid(row=1, column=1, pady=5)
name_label = Label(login_page, text="Name here:- ")
name_label.grid(row=0, column=0, pady=15)
password_label = Label(login_page, text="Password:- ")
password_label.grid(row=1, column=0, pady=5)
# LOG IN BUTTON
login_btn = Button(login_page, text="LOG IN", command=check_pass)
login_btn.grid(row=2, column=0, columnspan=2, ipadx=100, padx=5)
username = log_name.get()
userpass = log_pass.get()
name = "admin"
password= "admin"
mainloop()
慕盖茨4494581
相关分类