Commit e6faea14 by BellCodeEditor

auto save

parent 145fe74a
Showing with 43 additions and 9 deletions
import tkinter
from tkinter import messagebox
#载入json模块
import json
#读取user.txt的内容,并转换为字典
with open("user.txt",'r',encoding='utf-8') as f:
info = f.read()
users = json.loads(info)
def login_to_reg(): # 登录界面转注册界面
pass
#关闭登录窗口 窗口对象.destroy()
app_login.root.destroy()
#生成一个全局变量app_reg,用来实例化注册界面
global app_reg
app_reg = My_register()
#调用注册界面的show()方法来让窗口显示出来
app_reg.show()
def reg_to_login(): # 注册界面转登录界面
pass
#关闭注册窗口,窗口对象.destroy()
app_reg.root.destroy()
#生成一个全局变量app_login,用来实例化登录界面
global app_login
app_login = My_login()
app_login.show()
def register(): # 注册验证
pass
#先要获得账号,密码,确认密码
name,password,epassword = app_reg.get_input()
#三条有任意一条为空
if name == "" or password == "" or epassword == "":
#messgebox.showerror(标题,提示信息) 功能:报一个错误信息
messagebox.showerror("错误","注册信息不能为空")
elif password != epassword:
messagebox.showwarning("警告","两次密码不一致")
elif name in users:
messagebox.showwarning("警告","账号已被注册")
else:
users[name] = password
count = json.dumps(users)
with open("user.txt",'w',encoding='utf-8') as f:
f.write(count)
messagebox.showinfo("成功","注册成功")
reg_to_login()
def login(): # 登录验证
pass
......@@ -103,5 +137,5 @@ class My_register(): # 注册窗口
self.password2 = self.e3.get()
return self.name, self.password1, self.password2
app_login = My_login()
app_login.show()
\ No newline at end of file
app_login = My_login() #登录窗口
app_login.show()#调用显示模块
\ No newline at end of file
{"admin": "123456"}
\ No newline at end of file
{"admin": "123456", "aaa": "789"}
\ 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