
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Put Toplevel Window in Front of Main Window in Tkinter
The Tkinter Toplevel window creates an additional window apart from the main window. We can add widgets and components to the newly created top-level window. It supports all the properties of the parent or main window.
Sometimes the Toplevel window is also referred to as the child window. To put the child window in front of the parent window, we can use the wm_transient() method.
Example
# Import the required libraries from tkinter import * from tkinter import ttk # Create an instance of tkinter frame or window win=Tk() # Set the size of the window win.geometry("700x350") win.title("Parent Window") # Create a Toplevel window top=Toplevel(win) top.geometry('600x250') top.title("Child Window") # Place the toplevel window at the top top.wm_transient(win) win.mainloop()
Output
If we run the above code, it will display a Toplevel window in front of the main window.
Advertisements