Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way in Tkinter to create a pop up message?

I would like to create pop up messages like this in Tkinter. Is there a way to do it?Wordle Message Pop Up

I do not want a message pop up that requires the user to press a button or to react to disappear or messagebox module or a Toplevel object.

Thanks in advance.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If the popup is fully within the window, you can simply place a Label where you want the popup to show up and schedule a call to destroy it after some delay:

import tkinter as tk

root = tk.Tk()

def show_popup():
    label = tk.Label(root, text="This is a popup message!", bg="black", fg="white", wraplength=100)
    label.place(relx=0.5, rely=0.5, anchor="center")
    root.after(2000, label.destroy)

tk.Label(root, text="Some text here.").pack(padx=10, pady=10)
tk.Button(root, text="Show popup", command=show_popup).pack(padx=10, pady=10)

root.mainloop()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading