Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson20-diy3-2
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
3d627143
authored
Jul 20, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1ca0424b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
my_client.py
user.txt
my_client.py
View file @
3d627143
...
@@ -2,9 +2,6 @@ import tkinter
...
@@ -2,9 +2,6 @@ import tkinter
from
tkinter
import
*
from
tkinter
import
*
from
tkinter
import
messagebox
from
tkinter
import
messagebox
import
json
import
json
alist
=
[
"星期六下午打篮球"
,
"星期天下午和小美一起看电影"
,
"12月18日给蒂法过生日"
,
"12.24送妈妈圣诞礼物"
]
class
Note
():
# 便签、笔记
class
Note
():
# 便签、笔记
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -45,6 +42,9 @@ class Note(): # 便签、笔记
...
@@ -45,6 +42,9 @@ class Note(): # 便签、笔记
info
=
self
.
ent
.
get
()
info
=
self
.
ent
.
get
()
self
.
ent
.
delete
(
"0"
,
END
)
self
.
ent
.
delete
(
"0"
,
END
)
if
info
!=
""
:
if
info
!=
""
:
content
=
json
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
# "w"每次写入都覆盖原来的内容
file
.
write
(
content
)
alist
.
append
(
info
)
alist
.
append
(
info
)
self
.
canvas
.
create_text
(
40
,
self
.
y
,
text
=
info
,
font
=
(
"宋体"
,
11
),
self
.
canvas
.
create_text
(
40
,
self
.
y
,
text
=
info
,
font
=
(
"宋体"
,
11
),
anchor
=
W
,
fill
=
'#FF9900'
)
anchor
=
W
,
fill
=
'#FF9900'
)
...
@@ -56,6 +56,10 @@ class Note(): # 便签、笔记
...
@@ -56,6 +56,10 @@ class Note(): # 便签、笔记
def
remove
(
self
):
def
remove
(
self
):
num
=
self
.
v
.
get
()
num
=
self
.
v
.
get
()
alist
.
pop
(
num
)
alist
.
pop
(
num
)
content
=
json
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
# "w"每次写入都覆盖原来的内容
file
.
write
(
content
)
self
.
canvas
.
destroy
()
self
.
canvas
.
destroy
()
app
.
show
()
app
.
show
()
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
...
@@ -75,16 +79,16 @@ def reg_to_login(): # 注册界面转登录界面
...
@@ -75,16 +79,16 @@ def reg_to_login(): # 注册界面转登录界面
app_login
.
show
()
app_login
.
show
()
def
register
():
# 注册验证
def
register
():
# 注册验证
name
,
password
1
,
password2
=
app_reg
.
get_input
()
name
,
password
,
password1
=
app_reg
.
get_input
()
if
name
==
""
or
password
2
==
""
or
password1
==
""
:
if
name
==
""
or
password
==
""
or
password1
==
""
:
messagebox
.
showwarning
(
"警告"
,
"请填写完整的注册资料"
)
messagebox
.
showwarning
(
"警告"
,
"请填写完整的注册资料"
)
elif
name
in
users
:
elif
name
in
users
:
messagebox
.
showwarning
(
"错误"
,
"用户名已经存在!"
)
messagebox
.
showwarning
(
"错误"
,
"用户名已经存在!"
)
elif
password
1
!=
password2
:
elif
password
!=
password1
:
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致!"
)
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致!"
)
else
:
else
:
user_info
=
{}
user_info
=
{}
user_info
[
"password
1"
]
=
password1
user_info
[
"password
"
]
=
password
user_info
[
"event"
]
=
[
"提示1,:可以从输入框添加新任务"
,
"提示2:,点击前面输入框,表示任务完成"
]
user_info
[
"event"
]
=
[
"提示1,:可以从输入框添加新任务"
,
"提示2:,点击前面输入框,表示任务完成"
]
users
[
name
]
=
user_info
users
[
name
]
=
user_info
#users[name] = password1
#users[name] = password1
...
@@ -96,6 +100,22 @@ def register(): # 注册验证
...
@@ -96,6 +100,22 @@ def register(): # 注册验证
reg_to_login
()
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
=
users
[
name
][
"event"
]
app_login
.
root
.
destroy
()
global
app_reg
app
=
Note
()
app
.
show
()
app
.
root
.
mainloop
()
else
:
messagebox
.
showwarning
(
"错误"
,
"用户名或密码错误!"
)
class
My_login
():
# 登录窗口
class
My_login
():
# 登录窗口
def
__init__
(
self
):
def
__init__
(
self
):
...
@@ -187,19 +207,7 @@ class My_register(): # 注册窗口
...
@@ -187,19 +207,7 @@ class My_register(): # 注册窗口
self
.
password2
=
self
.
e3
.
get
()
self
.
password2
=
self
.
e3
.
get
()
return
self
.
name
,
self
.
password1
,
self
.
password2
return
self
.
name
,
self
.
password1
,
self
.
password2
def
login
():
# 登录验证
global
app
name
,
password
=
app_login
.
get_input
()
pwd
=
users
.
get
(
name
)
if
pwd
==
password
:
messagebox
.
showinfo
(
"成功"
,
"登录成功"
)
app_login
.
root
.
destroy
()
global
app_reg
app
=
Note
()
app
.
show
()
app
.
root
.
mainloop
()
else
:
messagebox
.
showwarning
(
"错误"
,
"用户名或密码错误!"
)
app_login
=
My_login
()
app_login
=
My_login
()
app_login
.
show
()
app_login
.
show
()
...
...
user.txt
View file @
3d627143
{"admin": "admin", "python": "123456", "111": "1111", "123": "123", "1234": {"password1": "123", "event": ["\u63d0\u793a1,:\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1", "\u63d0\u793a2:,\u70b9\u51fb\u524d\u9762\u8f93\u5165\u6846,\u8868\u793a\u4efb\u52a1\u5b8c\u6210"]}}
{"admin": "admin", "python": "123456", "111": "1111", "123": "123", "1234": {"password1": "123", "event": ["\u63d0\u793a1,:\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1", "\u63d0\u793a2:,\u70b9\u51fb\u524d\u9762\u8f93\u5165\u6846,\u8868\u793a\u4efb\u52a1\u5b8c\u6210"]}, "1": {"password1": "1", "event": ["\u63d0\u793a1,:\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1", "\u63d0\u793a2:,\u70b9\u51fb\u524d\u9762\u8f93\u5165\u6846,\u8868\u793a\u4efb\u52a1\u5b8c\u6210"]}, "11111": {"password": "1", "event": ["\u63d0\u793a1,:\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1", "\u63d0\u793a2:,\u70b9\u51fb\u524d\u9762\u8f93\u5165\u6846,\u8868\u793a\u4efb\u52a1\u5b8c\u6210"]}, "ke": {"password": "ke", "event": ["1231", "dfsfds"]}}
\ 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