废话不多说,直接上代码
from tkinter import Tk, Label, Entry, Button, messagebox
root = Tk()
username = "admin"
password = 12345678
def check():
global username, password
input_value = entry.get()
input_value_1 = entry_1.get()
if input_value == username and input_value_1 == password:
messagebox.showinfo(title=f"Landing results", message=f"Verified passed")
else:
messagebox.showwarning(title=f"Landing results", message=f"Wrong username or password")
def sign_in():
global root, username, password
Label(root, text="username:").pack()
entry_2 = Entry(root, show="")
entry_2.pack()
Label(root, text="password:").pack()
entry_3 = Entry(root, show="•")
entry_3.pack()
Label(root, text="Confirm your password:").pack()
entry_4 = Entry(root, show="•")
entry_4.pack()
def confirm_password():
global username, password
if entry_3.get() == entry_4.get() and len(entry_3.get()) >= 8 and entry_3.get() == int:
username = entry_2.get()
password = entry_3.get()
messagebox.showinfo(title=f"Registration result", message=f"Registration is successful")
else:
messagebox.showwarning(title=f"Registration result",
message=f"The password is inconsistent or the password length is less than eight")
Button(root, text="sign_in", command=confirm_password).pack()
def esc():
exit()
root.title("log in")
Label(root, text="Please enter a username:").pack()
entry = Entry(root, show="")
entry.pack()
Label(root, text="Please enter a password:").pack()
entry_1 = Entry(root, show="")
entry_1.pack()
Button(root, text="log in", command=check).pack()
label = Label(root, text="")
label.pack()
Button(root, text="sign in", command=sign_in).pack()
Button(root, text="exit", command=esc).pack()
root.mainloop()