Python tkinter did not succeed in writing the login window?

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()
Dec.16,2021
The

problem occurs here tkinter.Button (window, text= "Login", command=send_message ()) .grid (row=2, column=0) .
command=send_message () calls the function. Just enter and leave the function name here, and remove the parentheses. Change to tkinter.Button (window, text= "Login", command=send_message) .grid (row=2, column=0) .

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-34d2aa5-1c120.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-34d2aa5-1c120.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?