
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How do I create a popup window in Tkinter?
Popup window in Tkinter can be created by defining the Toplevel(win) window. A Toplevel window manages to create a child window along with the parent window. It always opens above all the other windows defined in any application. We can create a top-level window or child window by initializing the object of Toplevel(parent). It inherits all the property of its parent window such as geometry, title, and width or height.
Example
In this example, we will create a button that will open a Popup window above all the other windows.
#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of Tkinter frame win = Tk() #Set the geometry of Tkinter frame win.geometry("750x270") def open_popup(): top= Toplevel(win) top.geometry("750x250") top.title("Child Window") Label(top, text= "Hello World!", font=('Mistral 18 bold')).place(x=150,y=80) Label(win, text=" Click the Below Button to Open the Popup Window", font=('Helvetica 14 bold')).pack(pady=20) #Create a button in the main Window to open the popup ttk.Button(win, text= "Open", command= open_popup).pack() win.mainloop()
Output
Run the above code to display the output which contains a button and a Label Text.
When we click the "Open" button, it will open the popup window (top-level window) on the screen.
- Related Questions & Answers
- How do I create a popup window using Tkinter?
- How do I create a popup window using Tkinter Program?
- How do I close a tkinter window?
- How do I open a website in a Tkinter window?
- How do I set a minimum window size in Tkinter?
- How to create a Popup Menu in Tkinter?
- How do I position the buttons on a Tkinter window?
- How do I handle the window close event in Tkinter?
- How do I use Window Manager (wm) attributes in Tkinter?
- How do I create a date picker in tkinter?
- How do I insert a JPEG image into a Python Tkinter window?
- How do I get the width and height of a Tkinter window?
- How to create a popup chat window with CSS and JavaScript?
- How do I get rid of the Python Tkinter root window?
- Disable the underlying window when a popup is created in Python TKinter
Advertisements