I have the following problem. I created a gui with Tkinter and when I run it in my IDE (Spyder) everything works perfectly fine, but when I save the file as and want to start it by just executing the .py, everytime a window is created or a dialog opens, a second Tkinter window is poping up. Same problem appears when I save the code as .pyw . I posted a short example that lasts in the same Problem.
import tkinter as tk
from tkinter import messagebox
class test_GUI(tk.Frame):
def __init__(self,master=None):
super().__init__(master)
self._initializeWindow()
self._window.protocol("WM_DELETE_WINDOW", self.__on_closing)
self._window.mainloop()
def _initializeWindow(self):
self._window=tk.Tk()
self._window.title("The window I initzialized")
def __on_closing(self):
if(messagebox.askokcancel("Quit", "Quit program?")):
self._window.destroy()
self._window.quit()
app=test_GUI()