def play(audio):
sound = gTTS(audio)
sound.save('sound.mp3')
playsound('sound.mp3')
def isCorrect(self, n): # checking whether option clicked is correct or not and updating info
if n == self.anspos:
self.score = self.score + 1 # increasing score if correct
self.progress = self.progress + 1 # increasing progress
p.update()
if self.progress != 10:
p.newQues() # going for next question if 10 questions are not yet completed
else:
Prog.grid_forget(), Score.grid_forget(), Q.grid_forget() # removing unwanted labels and button
A.grid_forget(), B.grid_forget(), C.grid_forget(), D.grid_forget()
Result.grid(row="0", columnspan="2", pady="6", padx="10") # adding result label
final.set(("Congratulations!!,", "Your", "Score", "is", self.score, "/", "10")) # setting result in gui.
Quit.grid(row="1", column="1", padx="6", pady="10"), Restart.grid(row="1", column="0", padx="6", pady="10")
play(str(("Congratulations, Your Score is", self.score, "out of 10.")))
Here all the GUI part is in else
statement and that is executing after audio is played.
Just add window.update() before playing audio. window is tkinter.Tk()