Tkinter close window and open new Jan 13, 2022 · I n this tutorial, we are going to see how to close a Tkinter window with a Button. This documentation will concentrate on these additions and changes, and refer to the official Tcl/Tk documentation for details that are unchanged. I have tried so many method but not success class Ui_MainWindow (o Aug 24, 2024 · Creating Graphical User Interface (GUI) with TKinter in Python: Create New Windows in TKinter Introduction Python is a powerful and flexible programming language, but it is also used for creating … 3 days ago · Tkinter, Python’s built-in GUI library, is a popular choice for creating simple to moderately complex desktop applications. mainloop which terminates the program if the . Apr 10, 2024 · A step-by-step illustrated guide on how to close the Window in Tkinter in multiple ways. Chooser implements a modal color choosing dialog window. Tkinter provides several ways to create and manage pop-up windows in your Python applications. Apr 30, 2021 · In order to close a Tkinter application, we generally refer to close the parent window using the destroy () method. Apr 5, 2022 · In this article, we will be discussing how to close only the TopLevel window in Python Tkinter. To enable an object to be dragged, you must create an event binding for it that starts the drag-and-drop process. 2 days ago · The tkinter. My first installed ve… In a class, in a function I am creating a Tkinter Canvas. bt1? How is it possible to close NewWindow with use of bt_press method? python tkinter edited Feb 16, 2022 at Jun 9, 2022 · How to close the current window and open new window if condition is true (without any button clicked) and run the hole script again. Sep 15, 2023 · I want to switch between windows with customtkinter in Python. 1 day ago · The tkinter. Apr 10, 2016 · You probably don't want to have two Tk () instances running. window. ” 2 days ago · The tkinter. The Toplevel widget is used to provide some extra information to the user and also when our program deals with more than one application. Call Toplevel() if you want to create a new window. I am working with tkinter library in python. Sep 21, 2008 · 314 Tkinter supports a mechanism called protocol handlers. Jul 23, 2025 · Tkinter is the standard GUI (Graphical User Interface) library for Python. py will open and the old window will close. You should either create the window via a frame or class so that it's easy to recreate, or hide the window by calling . Is it possible to have one button do both of these? I've tried in the following code, but it hasn't worked, just told m Nov 21, 2023 · In this video we’ll look at the TopLevel Widget in CustomTkinter and Python. People usually mess this part up, either because the concept of Multiple Windows in Tkinter confuses them, or they end up quitting the entire Tkinter application, instead of just the TopLevel window. The mainloop is a built-in function in Tkinter that continuously listens for events and updates the GUI accordingly. Dec 24, 2014 · How would I be able to open a new window by the user pressing a button in a tkinter GUI? I only need quite simple solutions, and if the code could be explained as well that would be great. g. Also, the 'Help' button itself raises an error: >>> May 3, 2022 · Topic: How to Open a new Window with a button in Tkinter Python Module 2022 🔔 Subscribe to get New Videos Every Week: http://bit. Currently the button that creates the window, makes a small window that has a label, that just shows a command line based off user inputs on the GUI. It is responsible for keeping the window open and responsive. py (Github Code) from tkinter import * import customtkinter customtkinter. 7 and 3. mainloop() # Runs 'til i quit well, The rest of the code is just operations what i except is, When the user finishes and clicks the button (i have it in my code), the window is closed and a new window is opened my question is how can i close the previous window and where can i start and open the new Nov 2, 2021 · 0 I am working on a game called 'Flag Quiz' using tkinter. Sep 18, 2019 · With the following code you will be able to open a new window from the root window. How do you close a window in Python? Mar 7, 2024 · Output: A main window with a button labeled “Open popup”. In tkinter, we can create a Popup window or a child window by defining a Toplevel (master) constructor. Now that we have our back-end to your Tkinter GUI application, we're ready to use buttons to navigate to new frames and windows. Mar 7, 2024 · Method 1: Using the Toplevel widget This method involves creating a new instance of the Toplevel class, which is a standard way to create additional windows in Tkinter. Learn step-by-step how to enhance your Python applications with multiple windows, including code examples and customization tips. destroy (), etc but it still affects the main window. If the fourth button is pressed it asks you to press enter and then it and it's window disappears. However, many beginners (and even intermediate developers) struggle with getting this seemingly simple functionality to work. destroy is the only one that destroys any windows, apart from the python interpreter shutting down. py from tkinter import * Jul 23, 2025 · Python's Tkinter library offers a simple and effective way to create graphical user interfaces (GUIs) for your applications. I've tried all sorts of command lines like command=window. The solutions include root. To close both the new window and the main window, you can pass the latter to the former when you create it, and then destroy() that in your qExit() function (as well as the new window itself). Here is the code in qu @SheshanGamage . The following keyword arguments are applicable to the classes and functions listed below: Mar 5, 2023 · I just discovered why some functions doesn’t work properly in my script… Let me explain… So, using Tkinter, I created a root window where some function opens in it. How to only close This video covers how to work with multiple windows in tkinter. i already use root. . Use the Python Tkinter , create a sub-panel (TopLevel) to show something and get user input, after user inputed, clicked the "EXIT" found the whole GUI (main panel) also destory. I erased the command line for the exitbutton since I failed everytime lol. Just to warn all of you nice people: I'm relatively new to python and trying to write my first program. Is it possible to have one button do both of these? I've tried in the following code, but it hasn't worked, just told m Sep 25, 2016 · 3 This code opens a button, which links to another button. The button_open is inside the main window, hence in line 27 the main_window object is passed as the first argument. update () btn = Button (top,text='#Text of the exit button',command=exit_btn) Stepwise Implementation Step 1: First of all, import the library tkinter. Here is the result Mar 4, 2020 · I would like to know how I can open a tkinter window using python, and then later on in the script, it is closed to open another tkinter window. destroy and Mar 2, 2024 · Problem Formulation: When working with Python’s Tkinter library, you might encounter a situation where you have multiple windows open, and you want to close just the top-level one without terminating the entire application. Feb 6, 2025 · Example 2: A Tkinter Application with Multiple Windows Let’s say you’re building a Tkinter application for a US-based company that requires multiple windows. Mar 5, 2021 · I am doing some basic GUI programming in Python using tkinter. Let's call them 17 hours ago · Python has included the Tk interface module (tkinter) since versions 2. How do I close tkFileDialog? a little window with a tk keeps open. It provides additional benefits including anti-aliased font rendering under X11 and window transparency (requiring a composition window manager on X11). I want to add a piece of code that will close the new window when I click the EXIT button, and then return to the main window. ly/2UaSC5smore Nov 20, 2003 · The problem I'm stuck with is that once this function is done and I need to close the new window to go to the next window i again call the function which performs the "root. mainloop() main_window() Of course, there are a few hurdles such as the window shutting down as soon as it opens, but this is to show that you can create a new instance of a window from your program. The destroy () is a universal widget method i. mainloop () return (coordinates) print (mapper ()) while True Jul 12, 2025 · Toplevel widget A Toplevel widget is used to create a window on top of all other windows. 1 day ago · Source code: Lib/tkinter/font. Syntax: def exit_btn (): top. If I click on one of the buttons the recent mainmenu window disappears and a new tkinter window opens. quit doesn't close a window, it stops the . ). Note that you did not specify the parent in your Button() example and it is not recommended. What we do here will be your typical methodology for adding more and more pages, basically to infinity. In openCv there is the fonction IsOpen() to now if a camera is runing. I have a main window which has several buttons and when clicked those buttons a new window will popup which also has a button called cancel. Example In this example, we have created a button widget that will open the Hello I've been trying to create an exit button for my second window but whenever I would click the "End call" or close it, it affects the main window. I've searched a lot to find a solution to this simple problem, but didn't understan Apr 3, 2012 · You could create a class that extends the Tkinter Button class, that will be specialised to close your window by associating the destroy method to its command attribute: Sep 21, 2008 · How do I handle the window close event (user clicking the 'X' button) in a Python Tkinter program? How to open new window on button click in python? When a Tkinter program runs, it runs a mainloop (an infinite loop) which is responsible for running a GUI program. dnd module provides drag-and-drop support for objects within a single application, within the same window or between windows. It functions similarly to a Frame, but it opens in a separate window with properties like a title bar, minimize, maximize and close buttons, just like the main application window. By the end of this tutorial, you’ll be able to handle multiple windows in your Tkinter apps with ease. We’ll cover Tkinter’s focus-tracking methods, event handling, and practical examples tailored to Python 2. deiconify() to show it when ever you need it. We’ve done it yet into a post of some days ago, but in that code you could open the same window as many times as you wanted. i'm looking for the same thing in python to now if a window is started or if he is closed May 30, 2019 · Tkinter open and close Toplevel windows Asked 5 years, 10 months ago Modified 5 years, 10 months ago Viewed 1k times Apr 3, 2025 · Learn how to customize a Tkinter window in Python! Change the title, resize the window, set transparency, and update Feb 16, 2022 · At start both windows NewWindow and BasicWindow are displayd. enter(self) Bio. Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube. Jan 29, 2021 · Im trying to close my login wondow and open my register window once I click the sign up button but it doesn't destroy the login window Here is my login code from tkinter import * from tkinter impor Tkinter Toplevel to open child window on button click and to close child window from parent & child Jul 28, 2024 · When a Tkinter program runs, it runs a mainloop (an infinite loop) which is responsible for running a GUI program. It provides a powerful object-oriented interface to the Tk GUI toolkit. For the login screen there's two routes you could go. When this new window is closed, the new word will show up, but there will be two windows: new word + old word. Buttons may fail to respond, windows may close Discover how to effectively manage Tkinter windows in Python, including how to open a new window and close the previous one without errors. Feb 22, 2021 · Hello guys I want to make a button can close the main window (window01) and create new window (window02) This is my code but he does not working with me : from tkinter import * window01 = Tk() def Aug 25, 2015 · I'm new to PyQt5 and want to code a small programm I designed two Windows in QT Designer and convertet them into a py Script. I only want to open BasicWindow and NewWindow should be opened after button basic_bt is clicked. 5. This article delves into the intricacies of Tkinter's mainloop, exploring its purpose, operation, and impact on GUI applications. In my code below I can open the new window/file, but the old window is not closed. Perfect for beginners and experienced developers alike. Learn how to set up a `Tkinter` window in Python that can close and reopen itself with a simple button click or after a certain time interval. These windows are directly organized and managed by the Window Manager and do not need to have any parent window associated with them every time. The most commonly used protocol is called WM_DELETE_WINDOW, and is used to define what happens when the user explicitly closes a window using the window manager. mainloop() Tkinter Interactive Widgets In Python Tkinter, interactive widgets are the widgets that allow the users to interact with Once welcome appears a small tk window appears with four buttons, the fourth one being the relevant one. ---This video i Mar 15, 2022 · First, hello and thanks for assisting me with my Python/tkinter question! I would like to be able to close all open child windows and leave the root window open when closing them. after clicking on login button I wanted to close that initial window and open the 0 I am extremely new to Tkinter and must use this for my programming coursework, i am looking for help to understand how to I destroy/hide the LoginWindow when the SuccessfulLogin window is opened. It closes the window abruptly after calling it in any function or any widget. This function is being called by another class, I would like for the Tkinter window to pop up for 30 seconds and then close itself. destroy(). While the popup is open, the main window is disabled. quit methods. I have tried the 'quit' but it closed the whole program. This can either be a dedicated window, for example for error messages, or you can create completely new windows that can be used Jul 23, 2025 · The main Application Window is a graphical window with the title bar, minimize, maximize, and close buttons. Native Load/Save Dialogs ¶ The following classes and functions provide file dialog windows that combine a native look-and-feel with configuration options to customize behaviour. 1. close the current window and open a new one. 1 day ago · Tkinter, Python’s built-in GUI library, is a popular choice for creating simple to moderately complex desktop applications. I have looked up many examples but just can't quite see what I should put or where. That might sound confusing so let me explain. I want to close that login window when access is granted to a user, and open a new window. This can either be a dedicated window, for example for error messages, or you can create completely new windows that can be used 1 day ago · Tkinter is not a thin wrapper, but adds a fair amount of its own logic to make the experience more pythonic. set_appearance_mode("dark") # Modes: system Apr 22, 2021 · Tkinter creates a default window (i. One of the most fundamental interactions in any GUI app is closing a window—whether via a button, the system’s window manager (e. I have created two seperate classes for two windows. One of the most basic yet essential features of any GUI app is a button to close the window. Another approach would be to create both windows an call root. In the windows I am planning to just put images in s Feb 2, 2024 · This tutorial introduces how to close a Tkinter window with a button that has a function or command attached to it. Apr 28, 2021 · I have created a program in Python using tkinter. This will allow the tkinter application to create another window which can be resized dynamically by defining its size property. I was able to open the register page after clicking the Register button from the login page. Nov 6, 2024 · This post presents various methods for handling the window close event in a Tkinter application, providing practical examples and alternative approaches. 1 day ago · Tkinter is not a thin wrapper, but adds a fair amount of its own logic to make the experience more pythonic. , master or root window) for every application. Hello i try to build a programme with a root windows and other small windows (tk. At a time only one instance of mainloop can be active, so in order to open a new window we have to use a widget, Toplevel. I have a main window which has two buttons. I have a script called mainmenu where I can choose between an easy mode and a hard mode. Jul 28, 2025 · Memory Management: Always provide a way to close new windows, either through a close button or by handling the window close event. simpledialog module contains convenience classes and functions for creating simple modal 1 day ago · The tkinter. ttk module provides access to the Tk themed widget set, introduced in Tk 8. Aug 19, 2025 · Learn how to create a Python GUI program that generates a window and allows you to close it by clicking a 'Close' button. The same goes for the button_close and the secondary window on line 12. These methods allow for greater control and flexibility over how your program closes. However, many developers (especially beginners) struggle with Tkinter’s window Mar 4, 2021 · Creating an application using tkinter is easy but sometimes, it becomes difficult to close the window or the frame without closing it through the button on the title bar. withdraw() rather than . Each of these buttons open a specific child window but the problem is that the new windows Create and Open the New Window: Create a new instance of Tkinter for the new window after closing the main one. We can use a function or command associated with a button in the Tkinter GUI to close a Tkinter window when the user clicks on it. font module provides the Font class for creating and using named fonts. I have a tkinter window, root, which should close after a few seconds delay. The other button can close its self, but the first button can't close itself and open a new one at the same time, How do I fix this? Jul 18, 2021 · #destroying main window root. In this tutorial, you'll learn how to show an open file dialog in Tkinter applications. Note I Sep 19, 2022 · Bio. . The different font weights and slants are: 1 day ago · Standard builds of Python include an object-oriented interface to the Tcl/Tk widget set, called tkinter. Here is the code I currently have for my window: from tkinter import * root=Tk() def WaitAndClose(): global root # Apr 10, 2025 · Pop-up windows, also known as dialog boxes or secondary windows, are essential for displaying additional information, prompting for user input, or showing alerts in graphical user interfaces. Thank you. com Creating a Python application with Tkinter that closes the current window and opens a new one involves several steps. Let’s begin. Jan 20, 2018 · If the button is clicked, I want to close the current window/file and open the new window/file. ---more Oct 29, 2022 · I am a noob and maybe I am missing something really simple, but for some reason clicking on the button does not open a new window and doesn't do anything. What if you do want to prevent the chance for the user to open it more times, but just create it once? Aug 29, 2020 · Unfortunately, there's no easy way that I know of to just link a preexisting project to a new tkinter window, so you'll have to change your app a little bit to make it use the new window instead of the main menu window, for example. Creating new toplevel windows works almost exactly the same as creating new widgets. set_appearance_mode("dark") # Modes: system Nov 21, 2023 · In this video we’ll look at the TopLevel Widget in CustomTkinter and Python. Hello r/learnpython I'm currently building a holiday-package program, but I'm struggling on how to close a Tkinter window after the user have given the coordinates (from a map) without stopping the entire script, since I'll like to do something with the coordinates that has been given def mapper (): (have a chunk of code) window. Mar 7, 2024 · Output: A main window with a button labeled “Open popup”. This prevents unnecessary windows from staying open and consuming system resources. Whether you're looking to clean up your interface or transition to another window, knowing how to properly get rid of the Creating and destroying windows We've seen that all Tk programs start out with a root toplevel window, and then widgets are created as children of that root window. I want it to close a window and open a new window when the button is pressed Apr 11, 2023 · im not good in python and that is my code which is user click on button then the project. ttk module. I started to study Tkinter just recently. I appreciate any help, thank you! Jul 28, 2025 · One common requirement in GUI development is the ability to open new windows from existing ones, often triggered by user actions like button clicks. Sep 3, 2021 · You can create a new window using Toplevel widget and then create other widgets inside that window the same as you create widgets in the root window. I have it Aug 8, 2022 · When we create a toplevel window, and then when we close the main window, all the toplevel windows are closing. Apr 7, 2019 · You shouldn't call tkinter. Super useful for all sorts of things, and really easy to do with CustomTkinter! Python Code: ctk_new_window. my software should have Aug 30, 2016 · I have a login window. You can wait for user input to see whether or not the window will open or close. from tkFileDialog import askopenfile, asksaveasfile I am using tkFileDialog and when I am done opening and creating a new file, a little window keeps open and then when I try to close it it says program not responding. after clicking on login button I wanted to close that initial window and open the Dec 9, 2020 · To close a tkinter window, we can use the destroy () method. The module is a binding to version 8. retrive(self) self. To close the Tkinter window automatically after a certain time limit, we have to use the after (time in ms, callback) method by specifying the time and the callback function which needs to be run after a certain time limit. In this Tkinter tutorial we will explain how you can close your TopLevel Window by calling the appropriate functions. Below is a step-by-step tutorial @SheshanGamage . withdraw() to hide one of the windows and call root. Conclusion Mastering the art of window closing in tkinter is crucial for creating robust and user-friendly applications. scrolledtext module provides a class of the same name which implements a basic text widget which has a vertical scroll bar configured to do the “right thing. I want a button in my window to open a new window and close the previous one. e. This article will dive deep into the process of opening new windows with buttons in Python Tkinter, exploring various techniques and best practices. I want to Apr 29, 2025 · Learn how to create and manage multiple windows in Python's Tkinter library. I would like to close the current tkinter window, and open a new tkinter window when the user inputs text into an entry widget. This is especially common in GUI applications where multiple dialogs or child windows are involved. Apr 20, 2021 · I am currently working on a password manager, where the initial window will ask for login or to create a password. 7. simpledialog — Standard Tkinter input dialogs: Source code: Lib/tkinter/simpledialog. I want it such that whe Mar 4, 2020 · I am making a text-based game where you choose the direction you want to go and am using the tkinter window to display the map. This comprehensive guide covers the use of Toplevel windows, frame management, and best practices for building multi-window GUI applications. 2 days ago · It provides a robust and platform independent windowing toolkit, that is available to Python programmers using the tkinter package, and its extension, the tkinter. , the window in which it is located) as the first argument. Clicking this button opens a popup window with text and a “Close” button. destroy and root. Further, on this main GUI, I have a “Back to Login Window” Button. I have tried some methods with my knowledge/search, but none of them worked fine. 1. You also generally don't need to call mainloop() more than once. I am opening the other window by clicking on the button of one window. Apr 28, 2021 · In this case I would use new instances of Tk. but the old window did not close. When I try to call it a second time it tells me: TclError: can't invoke "destroy" command: application has been destroyed Click to expand May 4, 2024 · I have a simple tkinter logIn page that contains a login button. What Mar 26, 2018 · When I make a button that closes the current window and opens another, the current window doesn't close. That's OK normally, but how can we make it, so it can stay when we the main windows close. destroy () top. quit () new_window = Tk () Jul 10, 2025 · In this Python Tkinter tutorial, I will show you how to create and manage multiple windows in a GUI application. 5 of the Tk GUI suite for making windowing applications. A Toplevel widget works pretty much like a Frame, but it opens in a separate top-level window, such windows have all the properties that a main window (root Jul 21, 2020 · 1 Currently I am trying to destroy toplevel window (If it's there, if not create it) and spawn a new one in its place. Afterwards i merged both into one file (maybe my attempt is totaly wro Learn how to set up a `Tkinter` window in Python that can close and reopen itself with a simple button click or after a certain time interval. Examples of handling window events related to resizing, moving, and closing an application window in tkinter Here we'll discuss several methods used to close a Tkinter Window. The TopLevel widget allows you to add new windows to your app, besides the main window. , the "X" button in the corner), or a custom action. scale). Jul 12, 2025 · To create multiple windows in a Tkinter application, we use the Toplevel widget. Tk() more than once in a tkinter application. Solving the Tkinter window activation problem requires careful management of window focus and activation. py The tkinter. root = Tk() root. hi guys, I'm writing a graphical interface with Tkinter for some of my scripts and I would very like to know what do you think about my code because unfortunately I'm not an expert. Furthermore, by using techniques like grab_set () and handling window close events properly, you can ensure a much smoother and Feb 23, 2013 · Normally, by just entering wrong information 5 times, it will create the 'Help' window successfully; however, it still keeps the original word (the one that could not be answered), open. py from tkinter import * 5 days ago · This guide will walk you through determining which Tkinter window is currently on top (active), implementing visual indicators (toolbuttons) to reflect window status, and ensuring closures only target the active window. Implement simple flags to prevent opening multipl Feb 28, 2022 · I'm new to Graphic User Interface using Python. mainloop is at the end of the program. Toplevel(root) Jul 18, 2020 · Do something when window is closed Tkinter? Tkinter provides a custom handler to close the window. Mar 23, 2022 · Having two different windows, whenever we create a widget (be it a button or any other), we must specify its parent window (i. However, when using Tkinter, you may encounter situations where you need to close or remove the root window, which is the main window of your GUI. filedialog module provides classes and factory functions for creating file/directory selection windows. The message boxes are modal and will return a subset of (True, False, None, OK, CANCEL, YES, NO) based on the user’s selection. messagebox module provides a template base class as well as a variety of convenience methods for commonly used configurations. The Toplevel window acts independently of the main window, meaning it can be moved, resized, or closed without affecting the main application. To close the window using the handler, we can use the destroy () method. colorchooser module provides the Chooser class as an interface to the native color picker dialog. Jul 18, 2021 · Is there a way to reopen a window after closing it using destroy () in tkinter? The short answer is "no". from tkinter import * Step 2: Now, create a GUI app using tkinter app=Tk() Step 3: Next, give a title to In this tutorial, you'll learn how to create multiple windows in a Tkinter application using the Toplevel class. Here, the term protocol refers to the interaction between the application and the window manager. destroy ()". If there is any better ways of doing this, that would be greatly appreciated, but I am happy with having a tkinter window close and open when a new window is called. destroy() root. For this last way, it doesn’t write datas into the csv file 5 days ago · This guide will walk you through determining which Tkinter window is currently on top (active), implementing visual indicators (toolbuttons) to reflect window status, and ensuring closures only target the active window. May 27, 2025 · Learn how to effectively manage child windows in Tkinter by detecting if they are already opened or closed. Bear in mind that i am new to tkinter. My problem: I got a main window (using tkinter) and a couple of other windows. 0 I am extremely new to Tkinter and must use this for my programming coursework, i am looking for help to understand how to I destroy/hide the LoginWindow when the SuccessfulLogin window is opened. Mar 11, 2025 · This tutorial shows how to create and open a new window by pressing a button in Tkinter. For other functions (to write datas in a csv file), I’ve programmed (inside them) to open a new window to have another one, while the root window is still open. Below is the code files: login. And if I close the second window, the old window will be closed as well. By understanding the different types of tkinter windows, customizing the closing behavior, and handling closing events, you can ensure a smooth interaction for your users. Sep 28, 2024 · The Tkinter mainloop Before diving into window closing methods, it is crucial to understand the concept of the Tkinter mainloop. Here’s how you can structure your code and use the mainloop(): import tkinter as tk from tkinter import ttk def open_settings_window(): settings_window = tk. This handle allows us to put the widgets on the window and reconfigure it as necessary. You could withdraw the root window and make the login screen a Toplevel withdrawing the root window upon the Toplevel's initialization window and once the login is successful destroy the toplevel and raise the root window. e we can use this method with any of the available widgets as well as with the main tkinter window. 1 day ago · tkinter. I will use the Toplevel widget to open new windows from the main window. How can I solve it? (already solved by commed below) Why the label text in basic_lb did not get some update after pressing self. Here is my mainmenu script: 1 day ago · The tkinter. Dec 13, 2023 · Download this code from https://codegive. Sep 7, 2015 · I was wondering if there was a way to open a new instance of Toplevel() and close the current one via the press of a button, i. On clicking this button, I want to close this login page and wants to open (or run) a new python file that displays main project GUI (that contains many tkinter widgets buttons, text boxes, labels etc. The code example demonstrates the creation of a simple popup window using the Toplevel widget. This is probably the easiest to install (since it comes included with most binary distributions of Python) and use. Once it has been destroyed, it is impossible to get back. Understanding how the mainloop works in Tkinter is essential for creating responsive and interactive applications. The basic strategy is to control how focus returns when a window is closed, explicitly setting it back to the parent window to avoid unexpected reactivations. from tkinter import * root = Tk () def new_window (): root. python how to open a new window tkinter GUI tutorial for beginners#python #new #window #tkinter #GUI #tutorial #beginners Mar 5, 2014 · In this new win