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
c48eb808
authored
Sep 11, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
307ac72d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
0 deletions
my_window.py
user.txt
my_window.py
0 → 100644
View file @
c48eb808
import
tkinter
import
json
# 初始化字典
usr_dc
=
{}
# 初始化提交事件
def
register
():
usr_name
=
usr
.
get
()
usr_psword
=
psword
.
get
()
usr_dc
=
{
usr_name
:
usr_psword
}
usr_h
=
str
(
usr_dc
)
file
=
open
(
'user.txt'
,
'w'
)
file
.
writelines
(
usr_h
)
file
.
close
()
print
(
usr_dc
)
# 建立窗口对象
root
=
tkinter
.
Tk
()
root
.
title
(
"注册"
)
# 设置窗口标题
root
.
geometry
(
"400x320+500+300"
)
# 设置窗口大小
root
.
resizable
(
width
=
False
,
height
=
False
)
# 禁止拉伸窗口
# 用户输入框
usr
=
tkinter
.
Entry
(
root
,
show
=
None
,
font
=
(
'微软雅黑'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成明文形式
usr
.
place
(
x
=
140
,
y
=
80
)
usr_text
=
tkinter
.
Label
(
root
,
text
=
"用户名:"
,
font
=
(
"微软雅黑"
,
12
),
fg
=
"black"
)
usr_text
.
place
(
x
=
60
,
y
=
80
)
# 密码输入框
psword
=
tkinter
.
Entry
(
root
,
show
=
"*"
,
font
=
(
"微软雅黑"
,
14
),
bg
=
"light grey"
,
width
=
18
)
psword
.
place
(
x
=
140
,
y
=
140
)
psword_text
=
tkinter
.
Label
(
root
,
text
=
"密 码:"
,
font
=
(
"微软雅黑"
,
12
),
fg
=
"black"
)
psword_text
.
place
(
x
=
60
,
y
=
140
)
# 确认密码输入框
psword_sc
=
tkinter
.
Entry
(
root
,
show
=
"*"
,
font
=
(
"微软雅黑"
,
14
),
bg
=
"light grey"
,
width
=
18
)
psword_sc
.
place
(
x
=
140
,
y
=
200
)
psword_sc_text
=
tkinter
.
Label
(
root
,
text
=
"确认密码:"
,
font
=
(
"微软雅黑"
,
12
),
fg
=
"black"
)
psword_sc_text
.
place
(
x
=
60
,
y
=
200
)
# 注册Tab欢迎栏栏
lab
=
tkinter
.
Label
(
root
,
text
=
'您好!欢迎来到建安市第一化工厂'
,
font
=
(
'微软雅黑'
,
12
),
fg
=
"white"
,
width
=
40
,
height
=
2
,
bg
=
"green"
)
lab
.
place
(
x
=
0
,
y
=
0
)
# 提交Button
button_push
=
tkinter
.
Button
(
root
,
text
=
"Push at Database"
,
bg
=
"lightyellow"
,
width
=
15
,
command
=
register
)
button_push
.
place
(
x
=
150
,
y
=
250
)
# 保持窗口监听
root
.
mainloop
()
user.txt
0 → 100644
View file @
c48eb808
{'admin': '114514'}
\ 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