Python Forum
[Tkinter] notify after x number of days.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] notify after x number of days.
#4
#Lazr60+ thanks man for the help but actually the program has to wait for some days where the program could be stoped in between the intervals of days ...For suppose if I have to run fun1 after 7 days and the program will be closed 1, 2 times and again started and will the program still run fun1? plz

from tkinter import *
from datetime import datetime, timedelta 
import pickle
from tkinter import messagebox

filename = "file.pk" #filename data stored as dic = {time:[name,item]}

root = Tk()

t = IntVar()
i = StringVar()
n = StringVar()

 
def Notification_On_Completing(n, i, t):
	return messagebox.showinfo("Completed", "Name:- {}, Item:-{}, in Days:-{}".format(n, i, t)) 


def Check_If_Time_Is_Over():   #my actual problem is in this function 
	 
	with open(filename, "rb") as f: 
		dic = pickle.load(f)
	 
	now = datetime.now()

	for i, j in dic: #trying to loop and check if the time == now() 
	        if i == now: 
	            Notification_On_Completing(j[0], j[1], i) #if its true return the key which is equal with its value

	        elif i =! now: #if now time i am tryinng to show how much time left
	        	print(i - now, "Time has left for name:-{}, item:-{}".format(j[0],j[1]))
	        else:
	        	root.after(10000, Check_If_Time_Is_Over)

def SaveTheDaysToNotify():

	now = datetime.now()
	time = t.get()  # days to wait beforer notifying
	item = i.get()  #item name    
	name = i.get()  #name 

	end = now + timedelta(days=time)  #adding today with the number of days to notify
	
	with open(filename.pk, "rb") as f: # avoiding the overide of the files
		dic = pickle.load(f)
	  
	dic= {end:[name, item]}  # saving a days to notify as dic which will also show the name , and item
	with open("file.pk", "wb") as f: #keeping record of the time time to notify
		pickle.dump(dic, f)
	  
    Check_If_Time_Is_Over()


#Gui starts from here

time1 = Entry(root,textvariable=t).pack()  #taking entry as of time, name and item
name1 = Entry(root,textvariable=n).pack()
item1 = Entry(root, textvariable=i).pack()

ss = Button(root,text="done",command=clicked).pack() #adding to the pickle database with format as dictionary as dic ={time:[name, item]}

root.mainloop()
Check_If_Time_Is_Over()

if __name__ == "__main__":
	main_()
this is what i tried......plz i need help
Reply


Messages In This Thread
notify after x number of days. - by Rupen_gurung - Apr-01-2018, 05:13 PM
RE: notify after x number of days. - by Gribouillis - Apr-01-2018, 06:22 PM
RE: notify after x number of days. - by Larz60+ - Apr-01-2018, 06:41 PM
RE: notify after x number of days. - by Rupen_gurung - Apr-02-2018, 07:58 AM
RE: notify after x number of days. - by Gribouillis - Apr-02-2018, 08:47 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020