When instantiating a class, it enters a function that opens a window (toplevel) that the user must choose a certain option so that the program can continue executing, for that in the code I added the statement wait_window()
.
I happen to be there without closing that window (waiting), but when I give it close to the main window with the X in the windows window, I see an error in the terminal after closing saying:
_tkinter.TclError: can not invoke "toplevel" command: application has been destroyed
What would come after closing the daughter window that was pausing the program would be some more statements and then create another window (Toplevel) that would continue with the execution of the program, there in that sentence is when I throw error, the funny thing is that it appears after close everything, as the execution of the program continues. If anyone has any idea of this and could give me a hand I appreciate it.
This is my code:
main.py:
import tkinter as tk
from tkinter import ttk
from App import App
root = tk.Tk()
root.title('programa prueba')
app = App(root)
app.mainloop()
App.py:
import tkinter as tk
from tkinter import ttk
from Win import Win
class App(tk.Frame):
def __init__(self, root=None):
tk.Frame.__init__(self, root)
self.pack(padx=(10, 10), pady=(10, 10))
self.create_widgets()
def create_widgets(self):
open_frame = tk.Frame(self)
ttk.Button(
open_frame,
text="Boton",
command=self.callback_button).pack()
open_frame.pack()
def callback_button(self):
top_level = tk.Toplevel(self)
self.new_window = Win(top_level,self)
self.new_window.pack()
self.new_window.wait_window()
top_level = tk.Toplevel(self)
Win.py:
import tkinter as tk
from tkinter import ttk
class Win(tk.Frame):
def __init__(self, parent,calc):
tk.Frame.__init__(self, parent)
self.pack(padx=(10, 10), pady=(10, 10))