Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson18-diy3
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
c67ccc8f
authored
May 03, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
53b0f1a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
12 deletions
my_app.py
user.txt
my_app.py
View file @
c67ccc8f
import
tkinter
,
json
with
open
(
'user.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
users
=
json
.
loads
(
f
.
read
())
with
open
(
'user.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
users
=
json
.
loads
(
f
.
read
())
from
tkinter
import
messagebox
def
login_to_reg
():
# 登录界面转注册界面
app_login
.
root
.
destroy
()
...
...
@@ -14,18 +13,16 @@ def reg_to_login(): # 注册界面转登录界面
app_login
.
show
()
def
register
():
# 注册验证
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 comp
e
leted!'
)
elif
a
in
users
:
messagebox
.
showerror
(
'Error'
,
'The username is existed!'
)
elif
b
!=
c
:
messagebox
.
showerror
(
'Error'
,
'The passwords is not fited!'
)
else
:
messagebox
.
showinfo
(
'Successed'
,
'The register is completed.'
)
messagebox
users
[
a
]
=
b
with
open
(
'user.txt'
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
json
.
dumps
(
users
))
reg_to_login
()
def
login
():
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.'
)
def
login
():
# 登录验证
a
,
b
=
get_input
()
if
class
My_login
():
# 登录窗口
def
__init__
(
self
):
self
.
root
=
tkinter
.
Tk
()
...
...
user.txt
View file @
c67ccc8f
{'a':'1'}
\ No newline at end of file
{"admin": "123456"}
\ 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