简体   繁体   中英

How to show alerts in tkinter?

I want to show alerts in tkinter in python. Is there anyone who can tell me how to show alerts?

You can use tkinter.messagebox to create a pop up that display an information, warning, or error

like:

tkinter.messagebox.showwarning(title = "Ooops",message = "Please choose another file")

More here:

tkinter.messagebox (Python 3 documentation)
Standard Dialogs (effbot tkinterbook)

add this code:

from tkinter import messagebox as mb

if you want to show an error use this:

mb.showerror(title = "", message = "")

but if you want to show a warning use this:

mb.showwarning(title = "", message = "")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM