I'm new to programming and I'm trying to make a typeracer kind of program but the while loop conflicts with other buttons in simpledialog(including the close button), making it impossible to quit halfway without ending the main.
import tkinter
from tkinter import simpledialog
from tkinter import messagebox
from datetime import datetime
import time
start = time.time()
answer = "She sells seashells on the seashore"
rounds = 1
messagebox.showinfo("TypeRacer","Test your typing speed by typing various texts as fast as possible.")
while rounds != 3:
question = simpledialog.askstring("Round "+str(rounds),answer)
if question != answer:
messagebox.showerror("Error!","Incorrect syntax")
elif question == answer:
messagebox.showinfo("You got it right!","Proceeding to the next round.")
rounds += 1
end = time.time()
f1 = end - start
f2 = int(f1)
f2 = datetime.fromtimestamp(f2)
f3 = f2.strftime("%M:%S")
messagebox._show("Well done!","Your time was: "+str(f3))