Commit c67ccc8f by BellCodeEditor

auto save

parent 53b0f1a7
Showing with 9 additions and 12 deletions
import tkinter,json import tkinter,json
with open('user.txt','r',encoding='utf-8')as f: with open('user.txt','r',encoding='utf-8')as f:users=json.loads(f.read())
users=json.loads(f.read())
from tkinter import messagebox from tkinter import messagebox
def login_to_reg(): # 登录界面转注册界面 def login_to_reg(): # 登录界面转注册界面
app_login.root.destroy() app_login.root.destroy()
...@@ -14,18 +13,16 @@ def reg_to_login(): # 注册界面转登录界面 ...@@ -14,18 +13,16 @@ def reg_to_login(): # 注册界面转登录界面
app_login.show() app_login.show()
def register(): # 注册验证 def register(): # 注册验证
a,b,c=app_reg.get_input() a,b,c=app_reg.get_input()
if a==''or b==''or c=='':messagebox.showwarning('Warning','The info is not completed!') if a==''or b==''or c=='':messagebox.showwarning('Warning','The info is not compeleted!')
elif a in users:messagebox.showerror('Error','The username is existed!') elif a in users:messagebox.showerror('Error','The username is existed!')
elif b!=c:messagebox.showerror('Error','The passwords is not fited!') elif b!=c:messagebox.showerror('Error','The passwords is not fited!')
else: else:
messagebox.showinfo('Successed','The register is completed.') messagebox
users[a]=b users[a]=b
with open('user.txt','w',encoding='utf-8')as f:f.write(json.dumps(users)) def login(): # 登录验证
reg_to_login() a,b=get_input()
def login(): if
a,b=get_input() # 登录验证
if a in users.get()and users[a]==b:messagebox.showinfo('Successed','The login is completed.')
else:messagebox.showerror('Error','The username or password is not right.')
class My_login(): # 登录窗口 class My_login(): # 登录窗口
def __init__(self): def __init__(self):
self.root = tkinter.Tk() self.root = tkinter.Tk()
......
{'a':'1'} {"admin": "123456"}
\ 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