Marcus Pólo Marcus Pólo - 1 month ago 19
Python Question

Close tkinter GUI without killing the app

I'm using Tkinter to create a GUI program on python 2.7.

At some point, I want to open an informative window and close it automatically later on, the problem is, when I call quit on it the whole application closes.

root = tk.Tk()
root.title("WINDOW")


def create_wnd(xxx, yyy):
yyy.destroy()

def run_wnd():
dialog = tk.Toplevel()
dialog.title("wnd2")


wnd_run_button = tk.Button(root, text="RUN", command=lambda:run_wnd())
wnd_run_button.pack()

root.mainloop()

Answer

Call .destroy() to progress_dialog after the task is finished.

progress_dialog.destroy()

This will safely quit the popup without killing the whole application.