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.

41 lines
1.3 KiB

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()
# MainPage(root) # 如果需要,取消注释此行并确保已正确导入主页面模块
else:
messagebox.showinfo(title='错误', message='账户或密码错误')
def main():
global root
root = tk.Tk()
root.title('智能家居系统-登录界面')
root.geometry("300x180")
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()