Commit a4633790 by BellCodeEditor

save project

parent 05d070fa
Showing with 31 additions and 24 deletions
......@@ -13,7 +13,8 @@ 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.box = PhotoImage(file='box.png')
def show(self): # 布置窗口界面
# 画布
self.canvas = tkinter.Canvas(self.root, width=300, height=340)
......@@ -29,34 +30,40 @@ class Note(): # 便签、笔记
self.but.place(x=240, y=305)
# 展示所有的文字
self.y = 20
self.val=0
self.v=IntVar()
for info in alist:
self.val = 0 # 单选框的value参数
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,width=25,height=15,value=self.val,variable=self.v,borderwidth=0,command=self.remove)
# 单选框组件
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.val += 1
self.y += 30
def remove(self):
num=self.v.get()
def remove(self): # 清除选中的任务事件
num = self.v.get()
alist.pop(num)
self.canvas.destroy()
app.show()
def get_info(self):
info = self.ent.get()
self.ent.delete("0", END)
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,width=25,height=15,value=self.val,variable=self.v,borderwidth=0,command=self.remove)
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.val += 1
self.y += 30
with open("user.txt", "r", encoding="utf-8") as f:
info = f.read()
users = json.loads(info)
......@@ -81,10 +88,11 @@ def register(): # 注册验证
messagebox.showwarning("错误", "用户名已经存在!")
elif password1 != password2:
messagebox.showwarning("错误", "两次密码不一致!")
else:
user_info={}
user_info["password"]=password1
user_info["event"]=["提示1:输入框添加任务","提示2:点选择表示完成"]
else: # 通过验证
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"每次写入都覆盖原来的内容
......@@ -95,12 +103,11 @@ def register(): # 注册验证
def login(): # 登录验证
global app
name,password = app_login.get_input()
name, password = app_login.get_input()
pwd = users.get(name)
if pwd == password:
app_login.root.destroy()
app=Note()
app = Note()
app.show()
app.root.mainloop()
else:
......@@ -197,5 +204,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
{"admin": "admin", "python": "123456", "11": {"password": "11", "event": ["\u63d0\u793a1:\u8f93\u5165\u6846\u6dfb\u52a0\u4efb\u52a1", "\u63d0\u793a2:\u70b9\u9009\u62e9\u8868\u793a\u5b8c\u6210"]}}
\ No newline at end of file
{"admin": "admin", "python": "123456", "11": {"password": "11", "event": ["\u63d0\u793a1:\u8f93\u5165\u6846\u6dfb\u52a0\u4efb\u52a1", "\u63d0\u793a2:\u70b9\u9009\u62e9\u8868\u793a\u5b8c\u6210"]}, "111": {"password": "111", "event": ["\u63d0\u793a1\uff1a\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1", "\u63d0\u793a2\uff1a\u70b9\u51fb\u524d\u9762\u9009\u62e9\u6846\uff0c\u8868\u793a\u4efb\u52a1\u5b8c\u6210"]}}
\ No newline at end of file
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