Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson18-diy1
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
01688c12
authored
Feb 13, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
a03cf3e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
my_app.py
user.txt
my_app.py
View file @
01688c12
...
...
@@ -4,8 +4,11 @@ import json
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
info
=
f
.
read
()
users
=
{}
if
info
!=
""
:
users
=
json
.
loads
(
info
)
print
(
users
)
print
(
users
)
# print(users)
def
login_to_reg
():
# 登录界面转注册界面
app_login
.
root
.
destroy
()
global
app_reg
...
...
@@ -19,6 +22,7 @@ def reg_to_login(): # 注册界面转登录界面
app_login
.
show
()
def
register
():
# 注册验证
print
(
app_reg
.
get_input
())
name
,
password1
,
password2
=
app_reg
.
get_input
()
if
name
==
""
or
password2
==
""
or
password1
==
""
:
messagebox
.
showwarning
(
"警告"
,
"请填写完整的注册资料"
)
...
...
@@ -28,7 +32,7 @@ def register(): # 注册验证
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致!"
)
else
:
users
[
name
]
=
password1
con
ntent
=
json
.
dumps
(
users
)
con
tent
=
json
.
dumps
(
users
,
ensure_ascii
=
False
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
# "w"每次写入都覆盖原来的内容
file
.
write
(
content
)
# 注册成功,跳往登陆界面
...
...
@@ -63,7 +67,7 @@ class My_login(): # 登录窗口
l
.
place
(
x
=
50
,
y
=
140
)
# Entry单行文本输入框:用户名、密码
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
self
.
e1
=
k
;
lhggyugguhuhuno9yu7hy
ib
,
bm
,
8
yyb
uuu
hkjn
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成明文形式
self
.
e2
=
tkinter
.
Entry
(
self
.
root
,
show
=
'*'
,
font
=
(
'宋体'
,
14
),
width
=
18
)
# 显示成密文形式
...
...
@@ -129,6 +133,7 @@ class My_register(): # 注册窗口
def
get_input
(
self
):
# 获取提交的注册信息
self
.
name
=
self
.
e1
.
get
()
print
(
"self.name"
,
self
.
name
)
self
.
password1
=
self
.
e2
.
get
()
self
.
password2
=
self
.
e3
.
get
()
return
self
.
name
,
self
.
password1
,
self
.
password2
...
...
user.txt
View file @
01688c12
{"测试": "123456", "ceshi": "111111", "名字": "123456", "中文": "1111111"}
\ 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