Commit 6bd9b638 by BellCodeEditor

save project

parent d93a22ab
Showing with 75 additions and 69 deletions
......@@ -3,70 +3,7 @@ from tkinter import *
from tkinter import messagebox
import json
alist = []
class Note(): # 便签、笔记
def __init__(self):
self.root = tkinter.Tk()
self.root.geometry('300x340+1000+200')
self.root.title("我的便签-待办事项")
self.root.resizable(width=False, height=False)
self.bg_img = tkinter.PhotoImage(file="bg.png")
self.box_img = 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)
# 按钮
self.but = tkinter.Button(self.root,text='添加',font=('宋体', 12),
bg="lightblue", width=5, command=self.get_info)
self.but.place(x=240, y=305)
# 展示所有的文字
self.y = 20
self.val = 0
self.v=tkinter.IntVar()
for info in alist:
r=tkinter.Radiobutton(self.root,text="",image=self.box_img,value=self.val,variable=self.v,width=25,height=10,borderwidth=0,command=self.remove)
r.place(x=-20,y=self.y-10)
self.canvas.create_text(40, self.y, text=info,
font=("宋体", 11), anchor=W, fill='#FF9900')
self.y += 30
self.val += 1
def get_info(self):
self.val = 0
self.v=tkinter.IntVar()
info = self.ent.get()
self.ent.delete("0", END)
if info != "":
alist.append(info)
content = json.dumps(users)
with open("user.txt", "w", encoding="utf-8") as file: # "w"每次写入都覆盖原来的内容
file.write(content)
r=tkinter.Radiobutton(self.root,text="",image=self.box_img,value=self.val,variable=self.v,width=25,height=10,borderwidth=0,command=self.remove)
r.place(x=-20,y=self.y-10)
self.canvas.create_text(40,self.y,text=info,font=("宋体",11),
anchor=W, fill='#FF9900')
self.y += 30
self.val += 1
def remove(self):
num = self.v.get()
alist.pop(num)
self.canvas.destroy()
content = json.dumps(users)
with open("user.txt", "w", encoding="utf-8") as file: # "w"每次写入都覆盖原来的内容
file.write(content)
self.show()
alist=[]
with open("user.txt", "r", encoding="utf-8") as f:
info = f.read()
......@@ -105,15 +42,17 @@ def register(): # 注册验证
messagebox.showinfo("成功", "注册成功")
reg_to_login()
def login(): # 登录验证
name, password = app_login.get_input()
def login(): # 登录验证
global name
global alist
name,password = app_login.get_input()
pwd = users.get(name)
if name!=None and pwd["password"]==password:
app_login.root.destroy()
app = Note()
alist=users[name]["event"]
app.show()
app.root.mainloop()
alist=users[name]["event"]
else:
messagebox.showwarning("错误", "用户名或密码错误!")
......@@ -207,6 +146,72 @@ class My_register(): # 注册窗口
self.password2 = self.e3.get()
return self.name, self.password1, self.password2
class Note(): # 便签、笔记
def __init__(self):
self.root = tkinter.Tk()
self.root.geometry('300x340+1000+200')
self.root.title("我的便签-待办事项")
self.root.resizable(width=False, height=False)
self.bg_img = tkinter.PhotoImage(file="bg.png")
self.box_img = 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)
# 按钮
self.but = tkinter.Button(self.root,text='添加',font=('宋体', 12),
bg="lightblue", width=5, command=self.get_info)
self.but.place(x=240, y=305)
# 展示所有的文字
self.y = 20
self.val = 0
self.v=tkinter.IntVar()
for info in alist:
r=tkinter.Radiobutton(self.root,text="",image=self.box_img,value=self.val,variable=self.v,width=25,height=10,borderwidth=0,command=self.remove)
r.place(x=-20,y=self.y-10)
self.canvas.create_text(40, self.y, text=info,
font=("宋体", 11), anchor=W, fill='#FF9900')
self.y += 30
self.val += 1
def get_info(self):
self.val = 0
self.v=tkinter.IntVar()
info = self.ent.get()
self.ent.delete("0", END)
if info != "":
alist.append(info)
users[name]["event"]=alist
content = json.dumps(users)
with open("user.txt", "w", encoding="utf-8") as file: # "w"每次写入都覆盖原来的内容
file.write(content)
r=tkinter.Radiobutton(self.root,text="",image=self.box_img,value=self.val,variable=self.v,width=25,height=10,borderwidth=0,command=self.remove)
r.place(x=-20,y=self.y-10)
self.canvas.create_text(40,self.y,text=info,font=("宋体",11),
anchor=W, fill='#FF9900')
self.y += 30
self.val += 1
def remove(self):
num = self.v.get()
alist.pop(num)
self.canvas.destroy()
users[name]["event"]=alist
content = json.dumps(users)
with open("user.txt", "w", encoding="utf-8") as file: # "w"每次写入都覆盖原来的内容
file.write(content)
self.show()
app_login = My_login()
app_login.show()
\ No newline at end of file
{"admin": "admin", "python": "123456", "1": "1", "3": {"password": "2", "event": ["tishi114154", "fsmdhf"]}}
\ No newline at end of file
{"admin": "admin", "python": "123456", "1": "1", "3": {"password": "2", "event": ["1111111111", "22222222222"]}}
\ 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