Commit 1c9594df by BellCodeEditor

auto save

parent d149b129
Showing with 10 additions and 5 deletions
...@@ -2,8 +2,6 @@ import tkinter ...@@ -2,8 +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):
...@@ -42,6 +40,9 @@ class Note(): # 便签、笔记 ...@@ -42,6 +40,9 @@ 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()
def get_info(self): def get_info(self):
...@@ -49,6 +50,9 @@ class Note(): # 便签、笔记 ...@@ -49,6 +50,9 @@ class Note(): # 便签、笔记
self.ent.delete("0", END) self.ent.delete("0", END)
if info != "": if info != "":
alist.append(info) alist.append(info)
content = json.dumps(users)
with open("user.txt", "w", encoding="utf-8") as file: # "w"每次写入都覆盖原来的内容
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.canvas.create_text(40, self.y, text=info, self.canvas.create_text(40, self.y, text=info,
...@@ -102,10 +106,11 @@ def register(): # 注册验证 ...@@ -102,10 +106,11 @@ def register(): # 注册验证
reg_to_login() reg_to_login()
def login(): def login():
global app # 登录验证 global app,alist # 登录验证
name, password = app_login.get_input() name, password = app_login.get_input()
user_name = users.get(name) user_name = users.get(name)
if user_name != None and user_name["password"] == password: if user_name != None and user_name["password"] == password:
alist = users[name]["event"]
app_login.root.destroy() app_login.root.destroy()
app = Note() app = Note()
app.show() app.show()
......
{"admin": "admin", "python": "123456", "123": {"password": "123", "event": ["\u63d0\u793a1\uff1a\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1\u63d0\u793a2\uff1a\u70b9\u51fb\u524d\u9762\uff0c\u4ee3\u8868\u4efb\u52a1\u5b8c\u6210"]}, "1": {"password": "123", "event": ["\u63d0\u793a1\uff1a\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1\u63d0\u793a2\uff1a\u70b9\u51fb\u524d\u9762\uff0c\u4ee3\u8868\u4efb\u52a1\u5b8c\u6210"]}} {"admin": "admin", "python": "123456", "123": {"password": "123", "event": ["\u63d0\u793a1\uff1a\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1\u63d0\u793a2\uff1a\u70b9\u51fb\u524d\u9762\uff0c\u4ee3\u8868\u4efb\u52a1\u5b8c\u6210"]}, "1": {"password": "123", "event": ["\u63d0\u793a1\uff1a\u53ef\u4ee5\u4ece\u8f93\u5165\u6846\u6dfb\u52a0\u65b0\u4efb\u52a1\u63d0\u793a2\uff1a\u70b9\u51fb\u524d\u9762\uff0c\u4ee3\u8868\u4efb\u52a1\u5b8c\u6210"]}, "1234": {"password": "1234", "event": ["\u7684\u82e5\u5e72\u5929\u540e"]}}
\ No newline at end of file \ 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