Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson20-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
2aeac00c
authored
Feb 23, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
5c5ae725
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
17 deletions
__pycache__/code.cpython-37.pyc
__pycache__/my_client.cpython-37.pyc
code.py
my_client.py
__pycache__/code.cpython-37.pyc
0 → 100644
View file @
2aeac00c
File added
__pycache__/my_client.cpython-37.pyc
0 → 100644
View file @
2aeac00c
File added
code.py
View file @
2aeac00c
import
tkinter
import
tkinter
from
tkinter
import
messagebox
from
tkinter
import
messagebox
import
json
import
json
import
my_client
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
info
=
f
.
read
()
info
=
f
.
read
()
users
=
json
.
loads
(
info
)
users
=
json
.
loads
(
info
)
...
@@ -27,7 +27,19 @@ def register(): # 注册验证
...
@@ -27,7 +27,19 @@ def register(): # 注册验证
elif
password1
!=
password2
:
elif
password1
!=
password2
:
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致!"
)
messagebox
.
showwarning
(
"错误"
,
"两次密码不一致!"
)
else
:
else
:
users
[
name
]
=
password1
# users[name] = password1
# content = json.dumps(users)
# with open("user.txt", "w", encoding="utf-8") as file: # "w"每次写入都覆盖原来的内容
# file.write(content)
# # 注册成功,跳往登陆界面
# messagebox.showinfo("成功", "注册成功")
# reg_to_login()
user_info
=
{}
user_info
[
"password"
]
=
password1
user_info
[
"event"
]
=
[
"提示1:可以从输入框添加新任务"
,
"提示2:点击前面选择框,表示任务完成"
]
users
[
name
]
=
user_info
content
=
json
.
dumps
(
users
)
content
=
json
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
# "w"每次写入都覆盖原来的内容
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf-8"
)
as
file
:
# "w"每次写入都覆盖原来的内容
file
.
write
(
content
)
file
.
write
(
content
)
...
@@ -35,11 +47,29 @@ def register(): # 注册验证
...
@@ -35,11 +47,29 @@ def register(): # 注册验证
messagebox
.
showinfo
(
"成功"
,
"注册成功"
)
messagebox
.
showinfo
(
"成功"
,
"注册成功"
)
reg_to_login
()
reg_to_login
()
def
login
():
# 登录验证
def
login
():
# 登录验证
# name, password = app_login.get_input()
# pwd = users.get(name)
# if pwd == password:
# messagebox.showinfo("成功", "登录成功")
# my_client.start()
# else:
# messagebox.showwarning("错误", "用户名或密码错误!")
global
app
,
alist
name
,
password
=
app_login
.
get_input
()
name
,
password
=
app_login
.
get_input
()
pwd
=
users
.
get
(
name
)
# 验证用户名、密码是否正确
if
pwd
==
password
:
user_name
=
users
.
get
(
name
)
messagebox
.
showinfo
(
"成功"
,
"登录成功"
)
if
user_name
!=
None
and
user_name
[
"password"
]
==
password
:
alist
=
users
[
name
][
"event"
]
app_login
.
root
.
destroy
()
my_client
.
start
()
# app = Note()
# app.show()
# app.root.mainloop()
else
:
else
:
messagebox
.
showwarning
(
"错误"
,
"用户名或密码错误!"
)
messagebox
.
showwarning
(
"错误"
,
"用户名或密码错误!"
)
...
@@ -134,4 +164,4 @@ class My_register(): # 注册窗口
...
@@ -134,4 +164,4 @@ class My_register(): # 注册窗口
return
self
.
name
,
self
.
password1
,
self
.
password2
return
self
.
name
,
self
.
password1
,
self
.
password2
app_login
=
My_login
()
app_login
=
My_login
()
app_login
.
show
()
app_login
.
show
()
\ No newline at end of file
my_client.py
View file @
2aeac00c
import
tkinter
import
tkinter
from
tkinter
import
*
from
tkinter
import
*
import
json
alist
=
[
"星期六下午打篮球"
,
"星期天下午和小美一起看电影"
,
alist
=
[
"星期六下午打篮球"
,
"星期天下午和小美一起看电影"
,
"12月18日给蒂法过生日"
,
"12.24送妈妈圣诞礼物"
]
"12月18日给蒂法过生日"
,
"12.24送妈妈圣诞礼物"
]
with
open
(
"user.txt"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
info
=
f
.
read
()
users
=
json
.
loads
(
info
)
class
Note
():
# 便签、笔记
class
Note
():
# 便签、笔记
def
__init__
(
self
):
def
__init__
(
self
):
self
.
root
=
tkinter
.
Tk
()
self
.
root
=
tkinter
.
Tk
()
# self.root = tkinter.Toplevel()
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
)
...
@@ -38,22 +41,55 @@ class Note(): # 便签、笔记
...
@@ -38,22 +41,55 @@ class Note(): # 便签、笔记
# self.select = tkinter.Radiobutton(self.canvas,image = self.box,value=self.val,variable=self.v,)
# self.select = tkinter.Radiobutton(self.canvas,image = self.box,value=self.val,variable=self.v,)
self
.
select
=
tkinter
.
Radiobutton
(
self
.
canvas
,
image
=
self
.
box
,
self
.
select
=
tkinter
.
Radiobutton
(
self
.
canvas
,
image
=
self
.
box
,
value
=
self
.
val
,
variable
=
self
.
v
,
width
=
25
,
height
=
15
,
value
=
self
.
val
,
variable
=
self
.
v
,
width
=
25
,
height
=
15
,
borderwidth
=
0
,
indicatoron
=
0
)
borderwidth
=
0
,
command
=
self
.
remove
)
#,indicatoron=0
self
.
select
.
place
(
x
=
0
,
y
=
self
.
y
)
self
.
select
.
place
(
x
=
-
20
,
y
=
self
.
y
-
10
)
self
.
val
+=
1
self
.
val
+=
1
self
.
y
+=
30
self
.
y
+=
30
def
get_info
(
self
):
def
get_info
(
self
):
info
=
self
.
ent
.
get
()
info
=
self
.
ent
.
get
()
self
.
ent
.
delete
(
"0"
,
END
)
self
.
ent
.
delete
(
"0"
,
END
)
if
info
!=
""
:
if
info
!=
""
:
# alist.append(info)
# self.canvas.create_text(40,self.y,text=info,font=("宋体",11),
# anchor=W, fill='#FF9900')
# self.select = tkinter.Radiobutton(self.canvas,image=self.box,
# value=self.val,variable=self.v,width=25, height=15,
# borderwidth=0,command=self.remove) #,indicatoron=0
# self.select.place(x=-20,y=self.y-10)
# self.val += 1
# self.y += 30
alist
.
append
(
info
)
alist
.
append
(
info
)
# 更新用户待办事项
content
=
json
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf8"
)
as
file
:
file
.
write
(
content
)
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'
)
# 单选框组件
self
.
select
=
tkinter
.
Radiobutton
(
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
self
.
y
+=
30
def
remove
(
self
):
num
=
self
.
v
.
get
()
app
=
Note
()
alist
.
pop
(
num
)
app
.
show
()
# 更新用户待办事项
app
.
root
.
mainloop
()
content
=
json
.
dumps
(
users
)
with
open
(
"user.txt"
,
"w"
,
encoding
=
"utf8"
)
as
file
:
file
.
write
(
content
)
# 重新渲染便签界面
self
.
canvas
.
destroy
()
app
.
show
()
# app.root.mainloop()
'''
自定义启动
'''
def
start
():
global
app
app
=
Note
()
app
.
show
()
app
.
root
.
mainloop
()
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