Todolist Remainder In Tkinter In Python – Python In Hindi – Is Article Me Ham Python Todolist Remainder App Create Karne Wale Hai Wo Bhi Step By Step |
Also Read – Python Project Ideas With Source Code
Todolist Remainder In Tkinter In Python
Is Todolist Remainder App Me Aap Create And Time Ke Sath Remainder Notification Show Hoga, Ise Ham Or Niche Example Se Dekhte Hai |
Sabse Pahle Ham Module Ko Import Karte Hai And Unke Sath Global Variable Bhi Create Karte Hai |
import tkinter import threading from tkinter import messagebox import sys tasks = [] timer = threading real_timer = threading ok_thread = True
Ab Ham add_list Function Create Karne Wale Hai, Jo Input Me Todo Name And Time Lega |
def add_list(text, hour): tasks.append([text, hour]) timer = threading.Timer(hour, time_passed, [text]) timer.start()
Ab Ham update_list Function Create Karne Wale Hai, Jo Time – Update Karte Rahega, Matlab Jo User 60 Sec Time Diya Hai To Hame Second Ko Minus Me Repeat Karna Hoga Jo Zero Par Chala Jaye |
def update_list(): if todolist.size() > 0: todolist.delete(0, "end") for task in tasks: todolist.insert("end", "[" + task[0] + "] Time left: " + str(task[1]) + " secondes")
Ab Hame time_passed Function Create Karne Wale Hai, Jo update_list Function Ka Time Complete Ho Jane Par Notification Show Karenga |
def time_passed(task): tkinter.messagebox.showinfo("Notification", "Time for : " + task)
Ab Ham real_time Function Create Karne Wale Hai, Jo Real Time Update Karta Rahega And Time Complete Ho jane Par Listbox Me Se Item Delete Kar Dunga |
def real_time(): if ok_thread: real_timer = threading.Timer(1.0, real_time) real_timer.start() for task in tasks: if task[1] == 0: tasks.remove(task) task[1] -= 1 update_list()
Ab Ham In Display Part Create Karne Wale Hai, And Button Ke Under In Function Ko Call Karne Wale Hai |
if __name__ == '__main__': # application app = tkinter.Tk() app.geometry("480x680") app.title("Todolist Remainder BY Danish Ali") app.rowconfigure(0, weight=1) # fenetre frame = tkinter.Frame(app) frame.pack() # widgets label = tkinter.Label(app, text="Enter work to do:", wraplength = 200, justify = tkinter.LEFT) label_hour = tkinter.Label(app, text="Enter time (secondes)", wraplength = 200, justify = tkinter.LEFT) todo = tkinter.Entry(app, width=30) time = tkinter.Entry(app, width=15) send = tkinter.Button(app, text='Add task', fg="#ffffff", bg='#6186AC', height=3, width=30, command=get_entry) quit = tkinter.Button(app, text='Exit', fg="#ffffff", bg='#EB6464', height=3, width=30, command=app.destroy) todolist = tkinter.Listbox(app) if tasks != "": real_time() # binding app.bind('<Return>', get_entry) # widgets placement label.place(x=0, y=10, width=200, height=25) label_hour.place(x=235, y=10, width=200, height=25) todo.place(x=62, y=30, width=200, height=25) time.place(x=275, y=30, width=50, height=25) send.place(x=62, y=60, width=50, height=25) quit.place(x=302, y=60, width=50, height=25) todolist.place(x=60, y = 100, width=300, height=300) app.mainloop() ok_thread = False sys.exit("FINISHED")
Ab Tak Jo Code Ko Explain Kiya Hai, Ab Ham In Code Ko Ek Sath Combine Karte Hai, And Fir Is Code Ko Run karte Hai |
Also Read – PNR Status API In Python
Final Code :
import tkinter import threading from tkinter import messagebox import sys tasks = [] timer = threading real_timer = threading ok_thread = True def get_entry(event=""): text = todo.get() hour = int(time.get()) todo.delete(0, tkinter.END) time.delete(0, tkinter.END) todo.focus_set() add_list(text, hour) if 0 < hour < 999: update_list() def add_list(text, hour): tasks.append([text, hour]) timer = threading.Timer(hour, time_passed, [text]) timer.start() def update_list(): if todolist.size() > 0: todolist.delete(0, "end") for task in tasks: todolist.insert("end", "[" + task[0] + "] Time left: " + str(task[1]) + " secondes") def time_passed(task): tkinter.messagebox.showinfo("Notification", "Time for : " + task) def real_time(): if ok_thread: real_timer = threading.Timer(1.0, real_time) real_timer.start() for task in tasks: if task[1] == 0: tasks.remove(task) task[1] -= 1 update_list() if __name__ == '__main__': # application app = tkinter.Tk() app.geometry("480x680") app.title("Todolist Remainder BY Danish Ali") app.rowconfigure(0, weight=1) # fenetre frame = tkinter.Frame(app) frame.pack() # widgets label = tkinter.Label(app, text="Enter work to do:", wraplength = 200, justify = tkinter.LEFT) label_hour = tkinter.Label(app, text="Enter time (secondes)", wraplength = 200, justify = tkinter.LEFT) todo = tkinter.Entry(app, width=30) time = tkinter.Entry(app, width=15) send = tkinter.Button(app, text='Add task', fg="#ffffff", bg='#6186AC', height=3, width=30, command=get_entry) quit = tkinter.Button(app, text='Exit', fg="#ffffff", bg='#EB6464', height=3, width=30, command=app.destroy) todolist = tkinter.Listbox(app) if tasks != "": real_time() # binding app.bind('<Return>', get_entry) # widgets placement label.place(x=0, y=10, width=200, height=25) label_hour.place(x=235, y=10, width=200, height=25) todo.place(x=62, y=30, width=200, height=25) time.place(x=275, y=30, width=50, height=25) send.place(x=62, y=60, width=50, height=25) quit.place(x=302, y=60, width=50, height=25) todolist.place(x=60, y = 100, width=300, height=300) app.mainloop() ok_thread = False sys.exit("FINISHED")
Output:


1 thought on “Todolist Remainder In Tkinter In Python – Python In Hindi”