I completed a small project but I do not understand why the Tkinter windows close. I would like the window to stay open so I can keep making it say what I entered as input. Why does it close the window? Any way I can fix it?
Thanks
import tkinter as tk
from tkinter import ttk
import pyttsx3
class Call(tk.Tk):
def __init__(self):
super().__init__()
self.title('Calling System')
self.geometry('500x300')
self.resizable(False, False)
self.numero_label = ttk.Label(self, text = 'Numéro Suivant :')
self.numero_label.place(x = 10, y = 50)
self.numero_box = tk.StringVar()
self.numero_box = ttk.Entry(self)
self.numero_box.place(x = 226, y = 45)
self.numero_box.focus()
self.effacer = ttk.Button(self, text = ('EFFACER'), command = self.efface)
self.effacer.place(x = 10, y = 200)
self.appeler = ttk.Button(self, text = ('APPELER'), command = self.appel)
self.appeler.place(x = 365, y = 200)
self.quitter = ttk.Button(self, text = ('QUITTER'), command = self.leave)
self.quitter.place(x = 365, y = 250)
def leave(self):
self.quit()
def efface(self):
self.numero = self.numero_box.delete(0, 'end')
self.numero_box.focus()
def appel(self):
self.engine = pyttsx3.init()
self.voices = self.engine.getProperty("voices")
self.engine.setProperty('rate', 170)
self.engine.setProperty("voice", self.voices[3].id) #changing the language
Tosay = ('Le numéro ' + self.numero_box.get() + ' est appelé à la caisse')
self.engine.say(Tosay)
self.engine.runAndWait()
print('Le numéro ' + self.numero_box.get() + ' est appelé à la caisse')
self.numero_box.delete(0, 'end')
self.numero_box.focus()
if __name__ == "__main__":
app = Call()
app.mainloop()