Commit 2b388249 by BellCodeEditor

auto save

parent 1d2a1d0a
Showing with 17 additions and 16 deletions
......@@ -11,13 +11,14 @@ class Note(): # 便签、笔记
self.root.title("我的便签-待办事项")
self.root.resizable(width=False, height=False)
self.bg_img = tkinter.PhotoImage(file="bg.png")
self.box = PhotoImage(file='box.png')
self.bg_box= tkinter.PhotoImage(file='box.png')
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,font=('宋体', 13),
bg="snow", width=25)
self.ent.place(x=10, y=310)
......@@ -27,19 +28,17 @@ class Note(): # 便签、笔记
self.but.place(x=240, y=305)
# 展示所有的文字
self.y = 20
self.val = 0 #单选框的value参数
self.v = IntVar() #设置关联变量
self.var=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.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.selet=tkinter.Radiobutton(self.canvas , image=self.bg_box,value=self.var,variable=self.v,width=25,height=15,borderwidth=0,command=self.remove)
self.selet.place(x=-20,y=self.y-10)
self.y += 30
def remove(self):
num =self.v.get()
num = self.v.get()
alist.pop(num)
#更新用户待办事项
content=json.dumps(users)
with open('user.txt','w',encoding='utf-8')as file:
file.write(content)
......@@ -55,13 +54,14 @@ class Note(): # 便签、笔记
file.write(content)
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)
self.select.place(x=-20 ,y=self.y-10)
self.val+=1
self.selet=tkinter.Radiobutton(self.canvas , image=self.bg_box,value=self.var,variable=self.v,width=25,height=15,borderwidth=0,command=self.remove)
self.selet.place(x=-20,y=self.y-10)
self.y += 30
with open("user.txt", "r", encoding="utf-8") as f:
info = f.read()
users = json.loads(info)
......@@ -89,8 +89,9 @@ def register(): # 注册验证
else:
user_info={}
user_info['password']=password1
user_info['event']=['提示1:在输入框添加新的任务','提示2:点击单选框,表示任务完成']
users[name] = user_info
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)
......@@ -99,11 +100,11 @@ def register(): # 注册验证
reg_to_login()
def login(): # 登录验证
global app,alist #把局部变量转换成全局变量
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']
alist = users[name]['event']
app_login.root.destroy()
app=Note()
app.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment