I'm trying to make a tkinter widget that will actively update. Please note, countdown() is called first!! My problem is that once I enter duration into countdown, it closes the old widget as it should(not seen here). However, the new widget, that has the countdown timer in it, does not even appear. If I hit stop in my IDE, the widget does pop up, with how much time was left when the process was stopped.
def update(start, finish):
timeRemaining = finish - start
timeDisplay = Label(text = "%s" % timeRemaining)
timeDisplay.pack(side = BOTTOM)
while True:
#check = timeRemaining.timetuple()
timeRemaining = str(finish - datetime.datetime.now())
timeDisplay.config(text=timeRemaining)
timeDisplay.pack()
time.sleep(.01)
def countdown(duration):
root.destroy()
title = Label(text = "Countdown")
title.pack()
duration = float(duration)
print(duration)
start = datetime.datetime.now()
startHours = int(duration / 60)
startMinutes = int(duration % 60)
startSeconds = (((duration%60) - startMinutes)*60)
finish = start + datetime.timedelta(hours = startHours, minutes = startMinutes, seconds = startSeconds)
update(start, finish)
I hope I gave enough information. If there's something in here that doesn't make sense without context, let me know.
Any ideas? Thanks.