Commit 3da227f9 by BellCodeEditor

save project

parent 6d2e613a
Showing with 14 additions and 3 deletions
...@@ -22,6 +22,18 @@ def register(): # 注册验证 ...@@ -22,6 +22,18 @@ def register(): # 注册验证
name,password1,password2=app_reg.get_input() name,password1,password2=app_reg.get_input()
if name==''or password1==''or password2=='': if name==''or password1==''or password2=='':
messagebox.showwarning("警告","请填写完整的注册资料") messagebox.showwarning("警告","请填写完整的注册资料")
elif name in users:
messagebox.showwarning("错误","用户名已存在!")
elif password1 !=password2:
messagebox.showwarning("错误","两次密码不一致!")
else:
users[name] =password1
content=json.dumps(users)
with open("user.txt","w",encoding="utf-8")as file:
file.write(content)
messagebox.showinfo("成功","注册成功")
login_show()
def login(): # 登录验证 def login(): # 登录验证
pass pass
...@@ -60,7 +72,6 @@ class My_login(): # 登录窗口 ...@@ -60,7 +72,6 @@ class My_login(): # 登录窗口
button1 = tkinter.Button(self.root, text='注册', bg="lightgreen", button1 = tkinter.Button(self.root, text='注册', bg="lightgreen",
fg="black", width=15, command=login_to_reg) fg="black", width=15, command=login_to_reg)
button1.place(x=230, y=220) button1.place(x=230, y=220)
# 进入消息循环,监听事件
self.root.mainloop() self.root.mainloop()
def get_input(self): # 获取输入的用户名、密码 def get_input(self): # 获取输入的用户名、密码
......
{"admin": "123456"} {"admin": "123456", "1234": "1234"}
\ No newline at end of file \ No newline at end of file
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