Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson17-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
385afc8e
authored
Jan 08, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
b08ff02a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
8 deletions
my_window.py
my_window.py
View file @
385afc8e
import
tkinter
import
json
def
register
():
name
=
e1
.
get
()
password1
=
e2
.
get
()
password2
=
e3
.
get
()
if
name
==
''
:
print
(
'用户名为空!'
)
elif
password2
!=
password1
:
print
(
'两次密码不一样'
)
elif
password1
==
''
:
print
(
'密码不能为空!'
)
else
:
x
=
{
name
:
password2
}
x
=
json
.
dumps
(
x
,
ensure_ascii
=
False
)
with
open
(
"1.txt"
,
"a"
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
x
)
with
open
(
'1.txt'
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
#文件读取操作
# 建立窗口对象
root
=
tkinter
.
Tk
()
...
...
@@ -19,21 +37,21 @@ e3.place(x = 140,y = 200)
# 注册界面上的文字标签
lab
=
tkinter
.
Label
(
root
,
text
=
'您好!请填写注册信息'
,
font
=
(
'宋体'
,
15
),
fg
=
"
black"
,
width
=
40
,
height
=
2
,
bg
=
"green
"
)
fg
=
"
white"
,
width
=
40
,
height
=
2
,
bg
=
"purple
"
)
lab
.
place
(
x
=
0
,
y
=
0
)
# 在输入框前展示文字标签:用户名:、密 码:、确认密码:
l0
=
tkinter
.
Label
(
root
,
text
=
'您好!请填写注册信息'
,
font
=
(
'宋体'
,
15
),
fg
=
'white'
,
width
=
40
,
height
=
2
,
bg
=
'
green
'
)
fg
=
'white'
,
width
=
40
,
height
=
2
,
bg
=
'
purple
'
)
l0
.
place
(
x
=
0
,
y
=
0
)
l1
=
tkinter
.
Label
(
root
,
text
=
'用户名:'
,
font
=
(
'宋体'
,
12
),
fg
=
'
red
'
)
fg
=
'
lightblue
'
)
l1
.
place
(
x
=
60
,
y
=
80
)
l2
=
tkinter
.
Label
(
root
,
text
=
'密码:'
,
font
=
(
'宋体'
,
12
),
fg
=
'
red
'
)
fg
=
'
lightblue
'
)
l2
.
place
(
x
=
60
,
y
=
140
)
l3
=
tkinter
.
Label
(
root
,
text
=
'确认密码:'
,
font
=
(
'宋体'
,
12
),
fg
=
'
red
'
)
l3
.
place
(
x
=
6
0
,
y
=
200
)
# 保持窗口监听,进入消息循环
fg
=
'
lightblue
'
)
l3
.
place
(
x
=
5
0
,
y
=
200
)
b
=
tkinter
.
Button
(
root
,
text
=
'提交'
,
bg
=
'lightpink'
,
width
=
15
,
command
=
register
)
b
.
place
(
x
=
150
,
y
=
250
)
root
.
mainloop
()
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