Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson17-diy2
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
73395cb8
authored
Jan 02, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
15179051
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
20 deletions
my_window.py
my_window.py
View file @
73395cb8
import
tkinter
from
tkinter
import
*
class
Cmds
():
def
__init__
(
self
,
states
):
self
.
state
=
states
# 建立窗口对象
root
=
tkinter
.
Tk
()
root
.
title
(
"注册"
)
# 设置窗口标题
root
.
geometry
(
"400x320+500+300"
)
# 设置窗口大小
def
replace_window
(
self
):
w
.
destroy
()
if
self
.
state
==
"zhuce"
:
self
.
state
=
"denglu"
self
.
window_B
()
elif
self
.
state
==
"denglu"
:
self
.
state
=
"zhuce"
self
.
window_A
()
# 输入框entry;用户输入框
e1
=
tkinter
.
Entry
(
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成明文形式
e1
.
place
(
x
=
140
,
y
=
80
)
# 密码输入框,左上角坐标:x:140,y:140
?
# 确认密码输入框,左上角坐标:x:140,y:200
?
def
window_A
(
self
):
global
w
w
=
Tk
()
w
.
title
(
"用户登录"
)
w
.
geometry
(
"500x350+500+200"
)
m
=
Menu
(
w
)
op
=
Menu
(
m
,
tearoff
=
False
)
m
.
add_cascade
(
label
=
"选项"
,
menu
=
op
)
op
.
add_command
(
label
=
"注册账号"
,
command
=
self
.
replace_window
)
op
.
add_command
(
label
=
"退出程序"
,
command
=
w
.
quit
)
w
.
config
(
bg
=
"#101010"
,
menu
=
m
)
w
.
resizable
(
False
,
False
)
l1
=
Label
(
w
,
text
=
"登录"
,
font
=
(
""
,
30
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l1
.
place
(
x
=
20
,
y
=
20
)
l
=
Label
(
w
,
text
=
"—"
*
50
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l
.
place
(
x
=
0
,
y
=
70
)
l2
=
Label
(
w
,
text
=
"账号:"
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l2
.
place
(
x
=
20
,
y
=
100
)
e1
=
Entry
(
w
,
font
=
(
""
,
20
))
e1
.
place
(
x
=
100
,
y
=
100
,
width
=
380
)
l3
=
Label
(
w
,
text
=
"密码:"
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l3
.
place
(
x
=
20
,
y
=
150
)
e2
=
Entry
(
w
,
font
=
(
""
,
20
),
show
=
"·"
)
e2
.
place
(
x
=
100
,
y
=
150
,
width
=
380
)
l4
=
Label
(
w
,
text
=
"确认密码:"
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l4
.
place
(
x
=
20
,
y
=
200
)
e3
=
Entry
(
w
,
font
=
(
""
,
20
),
show
=
"·"
)
e3
.
place
(
x
=
150
,
y
=
200
,
width
=
330
)
b
=
Button
(
w
,
font
=
(
""
,
20
),
text
=
"提交"
,
fg
=
"#0000FF"
,
bg
=
"#F0F0F0"
)
b
.
place
(
x
=
150
,
y
=
260
,
width
=
200
)
w
.
mainloop
()
# 注册界面上的文字标签
lab
=
tkinter
.
Label
(
root
,
text
=
'您好!请填写注册信息'
,
font
=
(
'宋体'
,
15
),
fg
=
"black"
,
width
=
40
,
height
=
2
,
bg
=
"green"
)
lab
.
place
(
x
=
0
,
y
=
0
)
# 在输入框前展示文字标签:用户名:、密 码:、确认密码:
?
def
window_B
(
self
):
global
w
w
=
Tk
()
w
.
title
(
"用户注册"
)
w
.
geometry
(
"500x350+500+200"
)
m
=
Menu
(
w
)
op
=
Menu
(
m
,
tearoff
=
False
)
m
.
add_cascade
(
label
=
"选项"
,
menu
=
op
)
op
.
add_command
(
label
=
"已有账号登录"
,
command
=
self
.
replace_window
)
op
.
add_command
(
label
=
"退出程序"
,
command
=
w
.
quit
)
w
.
config
(
bg
=
"#101010"
,
menu
=
m
)
w
.
resizable
(
False
,
False
)
l1
=
Label
(
w
,
text
=
"注册"
,
font
=
(
""
,
30
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l1
.
place
(
x
=
20
,
y
=
20
)
l
=
Label
(
w
,
text
=
"—"
*
50
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l
.
place
(
x
=
0
,
y
=
70
)
l2
=
Label
(
w
,
text
=
"账号:"
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l2
.
place
(
x
=
20
,
y
=
100
)
e1
=
Entry
(
w
,
font
=
(
""
,
20
))
e1
.
place
(
x
=
100
,
y
=
100
,
width
=
380
)
l3
=
Label
(
w
,
text
=
"密码:"
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l3
.
place
(
x
=
20
,
y
=
150
)
e2
=
Entry
(
w
,
font
=
(
""
,
20
),
show
=
"·"
)
e2
.
place
(
x
=
100
,
y
=
150
,
width
=
380
)
l4
=
Label
(
w
,
text
=
"确认密码:"
,
font
=
(
""
,
20
),
fg
=
"#FFFFFF"
,
bg
=
"#101010"
)
l4
.
place
(
x
=
20
,
y
=
200
)
e3
=
Entry
(
w
,
font
=
(
""
,
20
),
show
=
"·"
)
e3
.
place
(
x
=
150
,
y
=
200
,
width
=
330
)
b
=
Button
(
w
,
font
=
(
""
,
20
),
text
=
"提交"
,
fg
=
"#0000FF"
,
bg
=
"#F0F0F0"
)
b
.
place
(
x
=
150
,
y
=
260
,
width
=
200
)
w
.
mainloop
()
# 保持窗口监听,进入消息循环
root
.
mainloop
()
window
=
Cmds
(
"zhuce"
)
window
.
window_A
()
\ 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