Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson20-diy3-1
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
51919738
authored
Sep 23, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bfca0003
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
21 deletions
my_client.py
user.txt
my_client.py
View file @
51919738
import
tkinter
from
tkinter
import
*
import
tkinter
from
tkinter
import
messagebox
import
json
alist
=
[
"星期六下午打篮球"
,
"星期天下午和小美一起看电影"
,
"12月18日给蒂法过生日"
,
"12.24送妈妈圣诞礼物"
]
import
json
alist
=
[
"西江月·夜行黄沙道中"
,
"【宋】辛弃疾"
,
"明月别枝惊鹊,清风半夜鸣蝉"
,
"稻花香里说丰年,听取蛙声一片"
,
"七八个星天外,两三点雨山前"
,
"旧时茅店社林边,路转溪桥忽见"
]
class
Note
():
# 便签、笔记
def
__init__
(
self
):
...
...
@@ -54,6 +51,12 @@ class Note(): # 便签、笔记
self
.
val
+=
1
self
.
y
+=
30
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
info
=
f
.
read
()
users
=
json
.
loads
(
info
)
...
...
@@ -79,7 +82,11 @@ def register(): # 注册验证
elif
password1
!=
password2
:
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致!"
)
else
:
users
[
name
]
=
password1
user_info
=
{}
user_info
[
"password"
]
=
password1
user_info
[
"event"
]
=
{
"提示1"
:
"可以从输入框添加新任务"
,
"提示2"
:
"点击前面选择框表示任务完成"
}
users
[
name
]
=
user_info
content
=
json
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
# "w"每次写入都覆盖原来的内容
file
.
write
(
content
)
...
...
@@ -87,11 +94,13 @@ def register(): # 注册验证
messagebox
.
showinfo
(
"成功"
,
"注册成功"
)
reg_to_login
()
def
login
():
# 登录验证
def
login
():
global
app
# 登录验证
name
,
password
=
app_login
.
get_input
()
pwd
=
users
.
get
(
name
)
if
pwd
==
password
:
messagebox
.
showinfo
(
"成功"
,
"登录成功"
)
if
pwd
[
'password'
]
==
password
:
#messagebox.showinfo("成功", "登录成功")
app_login
.
root
.
destroy
()
app
=
Note
()
app
.
show
()
app
.
root
.
mainloop
()
...
...
@@ -118,8 +127,8 @@ class My_login(): # 登录窗口
l
.
place
(
x
=
50
,
y
=
140
)
# Entry单行文本输入框:用户名、密码
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成
明文
形式
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
'#'
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成
井号
形式
self
.
e2
=
tkinter
.
Entry
(
self
.
root
,
show
=
'*'
,
font
=
(
'宋体'
,
14
),
width
=
18
)
# 显示成密文形式
self
.
e1
.
place
(
x
=
120
,
y
=
80
)
...
...
@@ -148,8 +157,8 @@ class My_register(): # 注册窗口
def
show
(
self
):
# 注册界面的所有控件
# 用户名、密码、确认密码输入框
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
None
,
font
=
(
'宋体'
,
14
),
bg
=
"light grey"
,
width
=
18
)
# 显示成
明文
形式
self
.
e1
=
tkinter
.
Entry
(
self
.
root
,
show
=
'#'
,
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
)
...
...
@@ -189,9 +198,4 @@ class My_register(): # 注册窗口
return
self
.
name
,
self
.
password1
,
self
.
password2
app_login
=
My_login
()
app_login
.
show
()
app_login
.
show
()
\ No newline at end of file
user.txt
View file @
51919738
{"admin": "admin", "python": "123456"}
\ No newline at end of file
{"admin": "admin", "abc": {"password": "abc", "event": {"\u63d0\u793a1": "\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1", "\u63d0\u793a2": "\u70b9\u51fb\u524d\u9762\u9009\u62e9\u6846\u8868\u793a\u4efb\u52a1\u5b8c\u6210"}}}
\ 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