I'm doing a timer on Tkinter but so far I haven't found a good way to implement a countdown. I've tried with datetime and time but couldn't specifically do a 72 hour countdown. Instead of time going down, it only increases according to the local time of the machine. Can you help me?
Code and Image:
import tkinter as tk
import time
countdown = 259200
class Application():
def __init__(self):
self.main = tk.Tk()
self.main.geometry('700x500')
self.main.title('')
self.main.resizable(0,0)
self.CreateWidgets()
self.main.mainloop()
def CreateWidgets(self):
self.now = tk.StringVar()
self.framemain = tk.Frame(self.main)
self.framemainlabel = tk.Frame(self.framemain,bg='black')
self.frametime = tk.Frame(self.framemain,bg='grey')
self.frametiming = tk.Frame(self.frametime,bg='red')
self.timeto = tk.Label(self.frametime,text="TIME LEFT",bg='grey',font=('Trebuchet MS',30),anchor=tk.NW)
self.time = tk.Label(self.frametime,text=self.now,bg='red',font=('Alarm Clock',100))
self.framemain.place(relwidth=1,relheight=1)
self.frametime.place(relwidth=1,relheight=0.8,rely=0.2)
self.framemainlabel.place(relwidth=1,relheight=0.2)
self.frametiming.place()
self.timeto.pack()
self.time.pack()
self.Counting()
def Counting(self):
t=time.strftime('%I:%M:%S',time.localtime())
if t!='':
self.time.config(text=t)
self.main.after(100,self.Counting)
app = Application()