You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

6 months ago
import tkinter as tk
from tkinter import messagebox
from ZYM import a
def login_check(root, username_var, password_var):
name = username_var.get()
pwd = password_var.get()
if name == '123' and pwd == '123':
messagebox.showinfo(title='恭喜', message='登录成功')
xiaohui()
else:
6 months ago
messagebox.showinfo(title='错误', message='账户或密码错误,请重新登录')
6 months ago
def main():
global root
root = tk.Tk()
root.title('智能家居系统-登录界面')
6 months ago
root.geometry("200x180")
6 months ago
username_var = tk.StringVar()
password_var = tk.StringVar()
tk.Label(root).grid(row=0, column=0)
tk.Label(root, text='账户').grid(row=1,column=0)
tk.Entry(root, textvariable=username_var).grid(row=1, column=1)
tk.Label(root, text='密码').grid(row=2, column=0)
tk.Entry(root, textvariable=password_var).grid(row=2, column=1, pady=10)
tk.Button(root, text='登录', command=lambda: login_check(root, username_var, password_var)).grid(row=3, column=0, pady=10)
tk.Button(root, text='退出', command=root.quit).grid(row=3, column=1, pady=10, sticky=tk.E)
root.mainloop()
def xiaohui():
root.destroy()
a()
if __name__ == '__main__':
main()