Welcome folks today in this post we will be displaying popup
window to user whenever they clicked button inside the desktop app in tkinter. All the full source code of the application will be given below.
Get Started
First of all just install the following library using the pip
command as shown below
pip install tkinter
And then you want to make an app.py
file and copy paste the following code
app.py
# import everything from tkinter module
from tkinter import *
# import messagebox from tkinter module
import tkinter.messagebox
# create a tkinter root window
root = tkinter.Tk()
# root window title and dimension
root.title("When you press a button the message will pop up")
root.geometry('500x300')
# Create a messagebox showinfo
def onClick():
tkinter.messagebox.showinfo("Welcome to Coding Shiksha.", "Hi I'm am Gautam")
# Create a Button
button = Button(root, text="Click Me", command=onClick, height=5, width=10)
# Set the position of button on the top of window.
button.pack(side='bottom')
root.mainloop()
And now if you execute this python
script by typing the below command
python app.py