I am working on a GUI which allows user to decide whether to proceed with the script or to terminate it, but if user does not respond in 15 mins I want to kill the window and proceed with rest of the script automatically. I have used root.destroy() in a function but it only executes if there is response from the user.
import sys
import Tkinter
root = Tkinter.Tk()
"""def countdown(time):
if time==10:
root.destroy()
else:
time +=time """
def Yes_callback():
root.destroy()
return()
def No_callback():
root.destroy() #Kills GUI
sys.exit("There is an Overnight execution")#Stops script
return() # returns to prog
ask = Tkinter.Label(text="Do you have any overnight task to run?")
yes_button = Tkinter.Button(root,text="Yes", command = Yes_callback)
no_button = Tkinter.Button(root, text="No", command = No_callback)
ask.pack()
yes_button.pack()
no_button.pack()
#countdown(0)
root.mainloop()
I have tried using countdown function on trial basis but it doesn't work as without user response control doesn't come to countdown function. Is there any way I can accomplish this task?