- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the "wait_window" method do in Tkinter?
Tkinter has many inbuilt functions that power the application logic to make it more functional and maintainable. Tkinter has the wait_window() method which ideally waits for an event to happen and executes the event of the main window. The wait_window() method can be called after the event which needs to happen before the main window event.
The wait_window() method is useful in many applications where a particular event needs to be executed first before the main program.
In this example, we have created a toplevel window, which when gets destroyed, the event in the main window gets executed instantly.
# Import the required libraries from tkinter import * # Create an instance of tkinter frame win= Tk() # Set the size of the tkinter window win.geometry("700x350") # Add a Text widget in a toplevel window top= Toplevel(win) top.geometry("450x150") Label(top,text="This is a TopLevel Window", font= ('Aerial 17')).pack(pady=50) # Wait for the toplevel window to be closed win.wait_window(top) print("Top Level Window has been Closed!") win.destroy() win.mainloop()
Running the above code will display a Label text in a top-level window. The Main window waits for the top level window to get destroyed.
Once we close the top level window, the Main window closes too and prints a message on the screen.
Top Level Window has been Closed!
- What does the "===" operator do in Kotlin?
- What does "?:" do in Kotlin? (Elvis Operator)
- What does the if __name__ == "__main__": do in Python?
- What does "print >>" do in python?
- What does "with torch no_grad" do in PyTorch?
- What's the difference between "update" and "update_idletasks" in Tkinter?
- Difference between "fill" and "expand" options for tkinter pack method
- What does "return@" mean in Kotlin?
- Difference between "grid" and "pack" geometry managers in Tkinter
- "Makkal Needhi Maiam" what does it mean?
- What does "Strike Price" mean in Option Contracts?
- How to code the tkinter "scrolledtext" module?
- What's the difference between "!!" and "?" in Kotlin?
- Change the color of "tab header" in ttk.Notebook (tkinter)
- Bootstrap .tab("show") method