How to produce a popup message depending on user input in tkinter on python? How to produce a popup message depending on user input in tkinter on python? tkinter tkinter

How to produce a popup message depending on user input in tkinter on python?


You should be able to create your messages / dialog using the info below:

 # Python 3 from tkinter import messagebox # Python 2 import tkMessageBox as messagebox if case 1:      messagebox.showinfo("title 1", "message 1") else:      messagebox.showinfo("title 2", "message 2")

You typically only spawn custom windows for really custom info boxes / windows that do their own logic. For simple messages it suffices to use the built in message box. Even then you should just use Toplevel instead of spawning entirely new tk.Tk instances. Tk is just one big mainloop (hence using .mainloop()....) which processes events within it.

How you choose to display messages to a user is really open-ended you could even make a label that updates the text and shows / hides it appropriately etcetera.

If you want to do custom fonts etcetera which it looks like... without digging through all of your code... you'd actually have to go the Toplevel / widget route.