topic description
write a window in python tkinter
sources of topics and their own ideas
there is no response when pressing the login key, and the login failure information comes out in advance
related codes
what result do you expect? What is the error message actually seen?
import tkinter
import tkinter.messagebox
window = tkinter.Tk()
varName = tkinter.StringVar()
varName.set("")
varPwd = tkinter.StringVar()
varPwd.set("")
window.title("my window")
window.geometry("300x100")
tkinter.Label(window, text="User Name: ").grid(row=0)
input_account = tkinter.Entry(window, textvariable=varName)
input_account.grid(row=0, column=1)
tkinter.Label(window, text="User Pwd: ").grid(row=1)
input_password = tkinter.Entry(window, show="*", textvariable=varPwd)
input_password.grid(row=1, column=1)
def send_message():
account = input_account.get()
password = input_password.get()
if account == "111" and password == "111":
tkinter.messagebox.showinfo("", "")
else:
tkinter.messagebox.showerror("", message="")
tkinter.Button(window, text="Login", command=send_message()).grid(row=2, column=0)
def cancel():
varName.set("")
varPwd.set("")
tkinter.Button(window, text="Cancel", command=cancel()).grid(row=2, column=1)
window.mainloop()