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
f3117f0b
authored
Nov 01, 2025
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
145fe74a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
6 deletions
1.py
my_app.py
1.py
0 → 100644
View file @
f3117f0b
my_app.py
View file @
f3117f0b
import
tkinter
import
tkinter
,
json
from
tkinter
import
messagebox
#读出文件中的所有的信息,已经注册的信息
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
data
=
f
.
read
()
users
=
json
.
loads
(
data
)
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
#app_res.get_input()#获取注册界面输入的所有信息
name
,
password1
,
password2
=
app_res
.
get_input
()
print
(
name
,
password1
,
password2
)
if
name
==
None
or
password1
==
None
or
password2
==
None
:
messagebox
.
showwarning
(
"警告"
,
"信息不能为空"
)
elif
name
in
users
:
messagebox
.
showwarning
(
"警告"
,
"重名了,请重新命名"
)
elif
password1
!=
password2
:
messagebox
.
showwarning
(
"警告"
,
"两次密码不一致~"
)
else
:
#注册成功,并写入文件中
#将姓名和密码写入字典中
users
[
name
]
=
password1
#将新的的内容写入文件中
def
login
():
# 登录验证
pass
...
...
@@ -103,5 +127,5 @@ class My_register(): # 注册窗口
self
.
password2
=
self
.
e3
.
get
()
return
self
.
name
,
self
.
password1
,
self
.
password2
app_login
=
My_login
()
app_login
=
My_login
()
#实例化
app_login
.
show
()
\ 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