Commit ffc3aa24 by BellCodeEditor

auto save

parent 145fe74a
Showing with 32 additions and 6 deletions
import tkinter
import json
from tkinter import messagebox
with open('user.txt','r',encoding='utf-8') as f:
info = f.read()
info1 = json.loads(info) #json模块需要导入
name = ''
password1 = ''
password2 = ''
def login_to_reg(): # 登录界面转注册界面
pass
app_login.root.destroy()
global app_reg
app_reg = My_register()
app_reg.show()
def reg_to_login(): # 注册界面转登录界面
pass
app_reg.root.destroy()
global app_login
app_login = My_login()
app_login.show()
def register(): # 注册验证
pass
name,password1,password2= app_reg.get_input()
if name == '' or password1 == '' or password2 == '':
messagebox.showwarning('警告','请补全所有的注册信息!')
elif name in info1 :
messagebox.showwarning('警告','用户名已经被注册!')
elif password1 != password2:
messagebox.showwarning('警告','两次输入的密码不同,请重新输入')
else:
info1[name] = password1
info2 = json.dumps(info1)
with open('user.txt','w',encoding='utf-8') as f:
f.write(info2)
messagebox.showinfo('提示','恭喜,注册成功!')
def login(): # 登录验证
pass
......@@ -19,6 +44,7 @@ class My_login(): # 登录窗口
self.root.geometry('400x300+500+300')
self.root.resizable(width=False, height=False) # True可以拉伸,False不能拉伸
def show(self): # 登录界面的所有控件
# Label文本标签,界面提示信息
l = tkinter.Label(self.root, text='您好!请登录', bg='green',
......
{"admin": "123456"}
\ No newline at end of file
{"123": "123456", "python": "123456", "123212": "123"}
\ 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