from tkinter import *
from datetime import datetime, timedelta
import time
import pickle
from tkinter import messagebox, ttk
def done_():
item = e1.get()
name = e2.get()
time = e3.get()
now = datetime.now()
end = now + timedelta(days=e6)
with open(filename, "rb") as f:
dc = pickle.load(f)
dc[time] = [name, item]
with open(filename, "wb") as f:
pickle.dump(dc, f)
e1.set("")
e2.set("")
e3.set("")
check_time()
def notify_info(n, m, o)
root.bell()
messagebox.showinfo("Name:-{}", "Item:-{}\t, time:-{}".format(n, m, o))
def check_time():
with open(filename, "rb") as f:
sa = pickle.load(f)
now = datetime.now()
for s, j in sa.items():
if str(now) == s: #if time == now()
time = str(s)
name = sa[now][0]
item = sa[now][1]
return notify_info(name, item, time)
#how do i continusly check if the now() == time in dic until its true
else:
pass
root.after(100, check_time)
#root.after just popped so many windows
filename = "fuckup.pk"
def main_():
root = Tk()
root.title("V0.1")
e1 = StringVar()
e2 = StringVar()
e3 = IntVar()
check_time()
lbl = Label(root).pack()
en = Entry(root,textvariable=e1)
en.pack()
en1 = Entry(root, textvariable=e2)
en1.pack()
en2 = Entry(root, textvariable=e3)
en2.pack()
btn = Button(root,text="click",command=done_)
btn.pack()
root.after(10, check_time)
root.mainloop()
if __name__ == "__main__":
main_()
我正在尝试创建一个程序,它将输入名称,项目和时间。我希望程序将详细信息保存到pickle文件并检查现在是否是时间并显示名称和项目的通知。但是我无法弄清楚如何检查时间是否到来。如果now()是时间,我很难检查每一秒。