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
5b99c7ee
authored
Jul 21, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
145fe74a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
13 deletions
my_app.py
my_app.py
View file @
5b99c7ee
import
tkinter
import
tkinter
from
tkinter
import
messagebox
import
json
with
open
(
'user.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
info
=
f
.
read
()
users
=
json
.
loads
(
info
)
def
login_to_reg
():
# 登录界面转注册界面
def
login_to_reg
():
# 登录界面转注册界面
pass
app_login
.
root
.
distroy
global
app_reg
app_reg
=
My_register
app_reg
.
show
()
def
reg_to_login
():
# 注册界面转登录界面
def
reg_to_login
():
# 注册界面转登录界面
pass
app_reg
.
root
.
distroy
global
app_login
app_login
=
My_login
app_login
.
show
()
def
register
():
# 注册验证
def
register
():
# 注册验证
pass
name
,
password1
,
password2
=
app_reg
.
get_input
()
if
name
==
" "
or
password1
==
" "
or
password2
==
" "
:
messagebox
.
showwarning
(
"警,请填完整资料。"
)
elif
name
in
users
:
messagebox
.
showwarning
(
"错,名已在。"
)
elif
password1
!=
password2
:
messagebox
.
showwarning
(
"错,密不一致"
)
else
:
users
[
name
]
=
password2
content
=
json
.
dumps
(
users
)
with
open
(
'user.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
file
.
write
(
content
)
messagebox
.
showinto
(
'成。'
)
login_show
()
def
login
():
# 登录验证
def
login
():
# 登录验证
pass
class
My_login
():
# 登录窗口
class
My_login
():
# 登录窗口
def
__init__
(
self
):
def
__init__
(
self
):
self
.
root
=
tkinter
.
Tk
()
self
.
root
=
tkinter
.
Tk
()
self
.
root
.
title
(
"登录窗口"
)
self
.
root
.
title
(
"登录窗口"
)
self
.
root
.
geometry
(
'400x300+500+300'
)
self
.
root
.
geometry
(
'400x300+500+300'
)
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
# True可以拉伸,False不能拉伸
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
# True可以拉伸,False不能拉伸
def
show
(
self
):
# 登录界面的所有控件
def
show
(
self
):
# 登录界面的所有控件
# Label文本标签,界面提示信息
# Label文本标签,界面提示信息
l
=
tkinter
.
Label
(
self
.
root
,
text
=
'您好!请登录'
,
bg
=
'
green
'
,
l
=
tkinter
.
Label
(
self
.
root
,
text
=
'您好!请登录'
,
bg
=
'
pink
'
,
font
=
(
'宋体'
,
15
),
width
=
40
,
height
=
2
)
font
=
(
'宋体'
,
15
),
width
=
40
,
height
=
2
)
l
.
place
(
x
=
0
,
y
=
0
)
l
.
place
(
x
=
0
,
y
=
0
)
l
=
tkinter
.
Label
(
self
.
root
,
text
=
'用户名:'
,
font
=
(
"宋体"
,
12
),
l
=
tkinter
.
Label
(
self
.
root
,
text
=
'用户名:'
,
font
=
(
"宋体"
,
12
),
fg
=
"
black
"
)
fg
=
"
yellow
"
)
l
.
place
(
x
=
50
,
y
=
80
)
l
.
place
(
x
=
50
,
y
=
80
)
l
=
tkinter
.
Label
(
self
.
root
,
text
=
'密
码:'
,
font
=
(
"宋体"
,
12
),
l
=
tkinter
.
Label
(
self
.
root
,
text
=
'密码:'
,
font
=
(
"宋体"
,
12
),
fg
=
"black"
)
fg
=
"black"
)
l
.
place
(
x
=
50
,
y
=
140
)
l
.
place
(
x
=
50
,
y
=
140
)
# Entry单行文本输入框:用户名、密码
# Entry单行文本输入框:用户名、密码
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成明文形式
bg
=
"light grey"
,
width
=
18
)
# 显示成明文形式
self
.
e2
=
tkinter
.
Entry
(
self
.
root
,
show
=
'
*
'
,
font
=
(
'宋体'
,
14
),
self
.
e2
=
tkinter
.
Entry
(
self
.
root
,
show
=
'
7
'
,
font
=
(
'宋体'
,
14
),
width
=
18
)
# 显示成密文形式
width
=
18
)
# 显示成密文形式
self
.
e1
.
place
(
x
=
120
,
y
=
80
)
self
.
e1
.
place
(
x
=
120
,
y
=
80
)
self
.
e2
.
place
(
x
=
120
,
y
=
140
)
self
.
e2
.
place
(
x
=
120
,
y
=
140
)
...
...
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