import tkinter as tk
from tkinter import messagebox
def check_password():
if username_entry.get() == "admin" and password_entry.get() == "password":
messagebox.showinfo("登录成功", "欢迎使用MES系统!")
else:
messagebox.showerror("登录失败", "用户名或密码错误,请重试。")
root = tk.Tk()
root.title("MES系统")
username_label = tk.Label(root, text="用户名")
username_label.pack()
username_entry = tk.Entry(root)
username_entry.pack()
password_label = tk.Label(root, text="密码")
password_label.pack()
password_entry = tk.Entry(root, show="*")
password_entry.pack()
login_button = tk.Button(root, text="登录", command=check_password)
login_button.pack()
root.mainloop()
标签:username,界面,python,tk,mes,entry,password,root,pack
From: https://blog.51cto.com/u_16055028/8245899