- 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
How do I create child windows with Python tkinter?
The child window can be referred to as the independent window which is separated from the root or main window. In order to create a child window, we have to define a toplevel window which can be created manually using the Toplevel(win) method. In the method toplevel(root), we have to pass the main window as the parameter and further define the widgets if needed.
Let us create a child window which contains some widgets in it.
#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry and title of tkinter Main window win.geometry("750x250") win.title("Main Window") #Create a child window using Toplevel method child_w= Toplevel(win) child_w.geometry("750x250") child_w.title("New Child Window") #Create Label in Mainwindow and Childwindow label_main= Label(win, text="Hi, this is Main window", font=('Helvetica 15')) label_main.pack(pady=20) label_child= Label(child_w, text= "Hi, this is Child Window", font=('Helvetica 15')) label_child.pack() win.mainloop()
When we run the above code, it will display two windows: a Main window and a Child Window
- How to handle child windows in Selenium with python?
- Handling Child Windows with Cypress
- How do I use PIL with Tkinter?
- How do I create a date picker in tkinter?
- How do I create a popup window in Tkinter?
- How do I create a popup window using Tkinter?
- How do I create an automatically updating GUI using Tkinter in Python?
- How do I create an automatically updating GUI using Tkinter?
- How do I create a popup window using Tkinter Program?
- How to create a child window and communicate with parents in Tkinter?
- How do I change button size in Python Tkinter?
- How do I create a Python namespace?
- How do I close a tkinter window?
- How do I display tooltips in Tkinter?
- How do I get rid of the Python Tkinter root window?