Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson19-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
d6dd31cc
authored
Jun 29, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
39bdb55e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
11 deletions
client.py
client.py
View file @
d6dd31cc
import
tkinter
impor
t
tkinter
from
tkinter
import
from
tkinter
import
messagebox
import
json
alist
=
[
"星期六下午打篮球"
,
"星期天下午和小美一起看电影"
,
"12月18日给蒂法过生日"
,
"12.24送妈妈圣诞礼物"
]
class
Note
():
# 便签、笔记
class
Note
():
# 便签、笔记
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -9,9 +11,13 @@ class Note(): # 便签、笔记
...
@@ -9,9 +11,13 @@ class Note(): # 便签、笔记
self
.
root
.
geometry
(
'300x340+1000+200'
)
self
.
root
.
geometry
(
'300x340+1000+200'
)
self
.
root
.
title
(
"我的便签-待办事项"
)
self
.
root
.
title
(
"我的便签-待办事项"
)
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
self
.
bg_img
=
tkinter
.
photoimage
(
file
=
"bg.png"
)
self
.
box
=
photoimage
(
file
=
'box.png'
)
def
show
(
self
):
# 布置窗口界面
def
show
(
self
):
# 布置窗口界面
# 输入框
self
.
canvas
=
tkinter
.
canvas
(
self
.
root
,
width
=
300
,
height
=
340
)
# 输入框
self
.
canvas
.
create_image
(
0
,
0
,
image
=
self
.
bg_img
,
anchor
=
NW
)
self
.
canvas
,
place
(
x
=
0
,
y
=
0
)
self
.
ent
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
self
.
ent
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
13
),
bg
=
"snow"
,
width
=
25
)
font
=
(
'宋体'
,
13
),
bg
=
"snow"
,
width
=
25
)
self
.
ent
.
place
(
x
=
10
,
y
=
310
)
self
.
ent
.
place
(
x
=
10
,
y
=
310
)
...
@@ -19,10 +25,97 @@ class Note(): # 便签、笔记
...
@@ -19,10 +25,97 @@ class Note(): # 便签、笔记
self
.
but
=
tkinter
.
Button
(
self
.
root
,
text
=
'添加'
,
font
=
(
'宋体'
,
12
),
self
.
but
=
tkinter
.
Button
(
self
.
root
,
text
=
'添加'
,
font
=
(
'宋体'
,
12
),
bg
=
"lightblue"
,
width
=
5
,
command
=
self
.
get_info
)
bg
=
"lightblue"
,
width
=
5
,
command
=
self
.
get_info
)
self
.
but
.
place
(
x
=
240
,
y
=
305
)
self
.
but
.
place
(
x
=
240
,
y
=
305
)
self
.
val
=
0
self
.
v
=
intvar
()
for
info
in
alist
:
self
.
canvas
.
create_text
(
40
,
self
.
y
,
text
=
info
,
font
=
(
"宋体"
,
11
),
anchor
=
w
,
fill
=
'#FF9900'
)
self
.
select
=
tkinter
.
redioutton
(
self
.
canvas
,
image
=
self
.
box
,
value
=
self
.
val
,
variable
=
self
.
v
,
width
=
25
,
height
=
15
borderwidth
=
0
,
command
=
self
.
remove
)
self
.
select
.
place
(
x
=-
20
,
y
=
self
.
y
-
10
)
self
.
val
+=
1
self
.
y
+=
30
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
info
=
f
.
read
()
users
=
json
.
loads
(
info
)
def
longin_to_reg
():
app_login
.
root
.
destroy
()
global
app_reg
app_reg
=
my_register
()
app_reg
.
show
()
def
reg_to_login
():
app_reg
.
root
.
destroy
()
global
app_reg
app_login
=
my_login
()
app_login
.
show
()
def
register
():
name
,
password2
=
app_reg
.
get_inpurt
()
if
name
==
""
or
password2
==
""
:
messagebox
.
showwarning
(
"警告"
,
"请填写完整注册资料"
)
elif
name
in
users
:
messagebox
.
showwarning
(
"错误"
,
"用户名已经存在"
)
elif
password1
!=
password2
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致"
)
else
:
user_info
{}
user_info
[
"passworld"
]
=
password1
user_info
[
"event"
]
=
[
"提示1:可以从输入框添加新任务"
,
"提示2:点击前面选择框,表示任务完成"
]
users_info
[
"name"
]
=
user_info
content
=
ison
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
file
.
write
(
content
)
messagebox
.
showinfo
(
"成功"
,
"注册成功"
)
reg_to_login
()
def
login
():
global
app
,
alist
name
,
password
=
app_login
.
get_input
()
user_name
=
users
.
get
(
name
)
if
user_name
!=
None
and
user_name
[
"password"
]
==
password
:
alist
=
user
[
name
][
"event"
]
app_login
.
root
.
destroy
()
app
=
Note
()
app
.
show
()
app
.
root
.
mainloop
()
else
:
messagebox
.
showwarning
(
"错误"
,
"用户密码错误"
)
def
get_info
(
self
):
class
My_login
()
pass
def
__init__
(
self
):
self
.
root
=
tkinter
.
TK
()
self
.
root
.
title
(
"登录窗口"
)
self
.
root
。
geometry
(
'400*300+500+300'
)
self
.
root
.
resizable
(
width
=
False
,
height
=
False
)
def
show
(
self
):
self
.
e1
=
tkinter
.
Eniry
(
self
.
root
,
show
=
Note
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
width
=
18
)
self
.
e1
.
place
(
x
=
140
,
y
=
80
)
self
.
e2
=
tkinter
.
Entry
(
self
.
root
,
show
=
'*'
,
font
=
(
'宋体'
,
14
)
width
=
18
)
self
.
e2
.
place
(
x
=
140
,
y
=
140
)
self
.
e3
=
tkinter
.
Entry
(
self
.
root
,
show
=
'*'
,
font
=
(
'宋体'
,
14
)
width
=
18
)
self
.
e3
.
place
(
x
=
140
,
y
=
200
)
lab
=
tkinter
.
Label
(
self
.
root
,
tetx
=
'您好请填写注册信息'
)
font
=
(
"宋体"
,
15
),
fg
=
"black"
,
width
=
40
,
height
=
2
,(
bg
=
"green"
)
lab
.
place
(
x
=
0
,
y
=
0
)
lab1
=
tkinter
.
Label
(
self
.
root
,
text
=
'用户名:'
,
font
=
(
"宋体"
,
12
),
fg
=
"black"
)
lab1
.
place
(
x
=
60
,
y
=
60
)
lab2
=
tkinter
.
Label
(
self
.
root
,
text
=
'密码:'
,
font
=
(
"宋体"
,
12
),
fg
=
"black"
)
lab2
.
place
(
x
=
60
,
y
=
140
)
lab3
=
tkinter
.
Label
(
self
.
root
,
text
=
'确认密码:'
,
font
=
(
"宋体"
,
12
),
fg
=
"black"
)
lab3
.
place
(
x
=
50
,
y
=
200
)
button1
=
tkinter
.
Button
(
self
.
root
,
text
=
'提交'
,
bg
=
"lightblue"
,
width
=
15
,
command
=
register
)
button1
.
place
(
x
=
230
,
y
=
250
)
button2
=
tkinter
.
Button
(
self
.
root
,
text
=
'取消'
,
bg
=
"lightblue"
,
width
=
15
,
command
=
reg_to_login
)
button2
.
place
(
x
=
80
,
y
=
250
)
self
.
root
.
mainloop
()
def
get_input
(
self
):
self
.
name
=
self
.
e1
.
get
()
self
.
password1
=
self
.
e2
.
get
()
self
.
password2
=
self
.
e3
.
get
()
return
self
.
name
,
self
.
password1
,
self
.
password2
app
=
Note
()
app_login
=
My_login
app
.
show
()
app_login
.
show
app
.
root
.
mainloop
()
\ No newline at end of file
\ 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