Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson18-diy2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cccb79d9
authored
Aug 20, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
b1a54cda
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
my_app.py
user.txt
my_app.py
View file @
cccb79d9
import
tkinter
from
tkinter
import
messagebox
import
json
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
file
:
a
=
file
.
read
()
toto
=
json
.
loads
(
a
)
def
login_to_reg
():
# 登录界面转注册界面
app_login
.
root
.
destroy
()
global
app_register
app_register
=
My_register
()
app_register
=
My_register
()
app_register
.
show
()
def
reg_to_login
():
# 注册界面转登录界面
...
...
@@ -12,8 +17,21 @@ def reg_to_login(): # 注册界面转登录界面
app_login
=
My_login
()
app_login
.
show
()
def
register
():
# 注册验证
pass
name
,
password1
,
password2
=
app_register
.
get_input
()
if
name
==
""
or
password1
==
""
or
password2
==
""
:
messagebox
.
showwarning
(
"错误"
,
"请填写完整注册信息!"
)
elif
name
in
toto
:
messagebox
.
showwarning
(
"错误"
,
"该用户名已被注册!"
)
elif
password1
!=
password2
:
messagebox
.
showwarning
(
"错误"
,
"两次密码不相符!"
)
else
:
toto
[
name
]
=
password1
cc
=
json
.
dumps
(
toto
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
'utf-8'
)
as
file
:
file
.
write
(
cc
)
messagebox
.
showinfo
(
"成功"
,
"注册成功"
)
reg_to_login
()
def
login
():
# 登录验证
pass
...
...
@@ -58,6 +76,7 @@ class My_login(): # 登录窗口
self
.
name
=
self
.
e1
.
get
()
self
.
password
=
self
.
e2
.
get
()
return
self
.
name
,
self
.
password
class
My_register
():
# 注册窗口
def
__init__
(
self
):
...
...
user.txt
View file @
cccb79d9
{"admin": "123456"}
\ No newline at end of file
{"admin": "123456", "23232323": "2323", "1111": "1111", "111": "111", "23333": "1111", "333333332": "2222"}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment