Commit 70725b29 by BellCodeEditor

save project

parent aa27860b
Showing with 15 additions and 7 deletions
import tkinter import tkinter
from tkinter import messagebox from tkinter import messagebox
import json import json
with open("user.txt","r",encoding="utf-8") as f:
with open("user.txt","r",encoding="utf-8") as file: info = f.read()
users = json.loads(info)
def login_to_reg(): # 登录界面转注册界面 def login_to_reg(): # 登录界面转注册界面
app_login.root.destroy() app_login.root.destroy()
global app_reg global app_reg
...@@ -19,18 +19,26 @@ def reg_to_login(): # 注册界面转登录界面 ...@@ -19,18 +19,26 @@ def reg_to_login(): # 注册界面转登录界面
def register(): # 注册验证 def register(): # 注册验证
name.password1,password2 =app_reg,get_input() name.password1,password2 =app_reg,get_input()
if name == ""or password2 ==""or password1 =="": if name == ""or password2 ==""or password1 =="":
messagebox.showwarning("警告!""请输入完整的注册信息") messagebox.showwarning("警告!","请输入完整的注册信息")
elif name in users: elif name in users:
wessagebox.showwarning("错误!","用户名已存在!") wessagebox.showwarning("错误!","用户名已存在!")
elif password1 !=password2: elif password1 !=password2:
wessagebox.showwarning("错误!","两次密码不一致!") wessagebox.showwarning("错误!","两次密码不一致!")
else else:
users[name] = password1 users[name] = password1
content = json.dumps(usert) content = json.dumps(usert)
with open("user.txt","r",encoding="utf-8") as file: with open("user.txt","r",encoding="utf-8") as file:
file.write file.write(content)
wessagebox.showinfo("成功","成功注册")
reg_to_login()
def login(): # 登录验证 def login(): # 登录验证
pass name = password = app_login.get_input()
pwd = users.get(name)
if pwd == password:
wessagebox.showinfo("成功","成功登录")
else:
wessagebox.showwarning("错误!","用户名或密码错误!")
class My_login(): # 登录窗口 class My_login(): # 登录窗口
def __init__(self): def __init__(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment