I am building an application in Tkinter with a custom window through overrideredirect. I have bound my self-designed X button to the function below. Closing the app using my button works fine, and it does fade out, but after a few seconds the window reappears, gets stuck in a loop (that's what it looks like) and crashes. It should just quit, which is what it did before I added the fadeout loop. Can someone tell me why the program reappears then crashes or offer a better alternative for a fadeout effect when closing the app (I know there are more sophisticated toolkits but I need to use Tkinter in this case)?
Thanks
def CloseApp(event):
if InProgress==False: #InProgress boolean defined elsewhere in program
if tkMessageBox.askokcancel("Quit","Do you really wish to quit?"):
n=1
while n != 0:
n -= 0.1
QuizWindow.attributes("-alpha", n)
time.sleep(0.02)
Window.destroy() #I've also tried using the quit() method, not that it would make a difference
else:
if tkMessageBox.askokcancel("Quit"," If you quit now you will lose your progress and have to start again. Are you sure you want to quit?"):
n=1
while n != 0:
n -= 0.1
QuizWindow.attributes("-alpha", n)
time.sleep(0.02)
Window.destroy()