WebNov 10, 2024 · import tkinter as tk class MainApplication (): def __init__ (self, parent): # Main window self.parent = parent but1 = tk.Button (self.parent, text="Main window", width = 30, command=self.sub_window) but1.pack () self.parent.protocol ("WM_DELETE_WINDOW", self.on_main_close) def sub_window (self): # Sub window … WebMar 29, 2024 · 1 Answer Sorted by: 0 You should use function instead of root.destroy in root.protocol ('WM_DELETE_WINDOW', ...) and call root.destroy () at the end of function ():
How to close main Tkinter window from pop up window in python?
WebNov 2, 2024 · When you use close button to close main window then it should also close all subwindows but when you close subwindow then it doesn't close main window (parent window) but only own subwindows - because usually it can be useful to display again main window to select other options and open again subwindow. Web2 days ago · tkinter python : open new window and close the old one. im not good in python and that is my code which is user click on button then the project.py will open and the old window will close. but the old window did not close. i already use root.destroy and still did not solve the problem. import tkinter as tk import os def start_game (): # Replace ... spring guide basic authentication
Close all windows except for the starting window in tkinter
WebMar 12, 2013 · 1 Answer Sorted by: 55 If you don't want to hide the root but just make sure the user can only interact with the popup, you can use grab_set () and grab_release (). b.grab_set () # when you show the popup # do stuff ... b.grab_release () # to return to normal Alternatively, you could withdraw () the root to make it invisible: a.withdraw () WebLet’s start with a simple program that consists of a window: import tkinter as tk root = tk.Tk () root.mainloop () Code language: Python (python) Output: The root window has a title that defaults to tk. It also has three system buttons including Minimize, Maximize, and Close. Let’s learn how to change the attributes of the root window. WebSep 8, 2024 · 1. I have a main tkinter window which launches multiple pop up windows. I am trying to close all windows by pressing the cross in the pop up window or by … spring guice