`!tkinter.messagebox` --- Tkinter message prompts
tkinter.messagebox
Source code: Lib/tkinter/messagebox.py
The !tkinter.messagebox module provides a template base class as well as a variety of convenience methods for commonly used configurations. The message boxes are modal: each blocks until the user responds, then returns a value that depends on the function. The show* functions and Message.show return the symbolic name of the button the user pressed, as a string (such as OK or YES). Common message box styles and layouts include but are not limited to:
Information message box
showinfo(title=None, message=None, **options)
Creates and displays an information message box with the specified title and message.
Warning message boxes
showwarning(title=None, message=None, **options)
Creates and displays a warning message box with the specified title and message.
showerror(title=None, message=None, **options)
Creates and displays an error message box with the specified title and message.
Question message boxes
askquestion(title=None, message=None, , type=YESNO,*options)
Ask a question. By default shows buttons YES and NO. Returns the symbolic name of the selected button.
askokcancel(title=None, message=None, **options)
Ask if operation should proceed. Shows buttons OK and CANCEL. Returns True if the answer is ok and False otherwise.
askretrycancel(title=None, message=None, **options)
Ask if operation should be retried. Shows buttons RETRY and CANCEL. Return True if the answer is retry and False otherwise.
askyesno(title=None, message=None, **options)
Ask a question. Shows buttons YES and NO. Returns True if the answer is yes and False otherwise.
askyesnocancel(title=None, message=None, **options)
Ask a question. Shows buttons YES, NO and CANCEL. Return True if the answer is yes, None if cancelled, and False otherwise.
Symbolic names of buttons:
ABORT
RETRY
IGNORE
OK
CANCEL
YES
NO
Predefined sets of buttons:
ABORTRETRYIGNORE
Displays three buttons whose symbolic names are ABORT, RETRY and IGNORE.
OK
Displays one button whose symbolic name is OK.
OKCANCEL
Displays two buttons whose symbolic names are OK and CANCEL.
RETRYCANCEL
Displays two buttons whose symbolic names are RETRY and CANCEL.
YESNO
Displays two buttons whose symbolic names are YES and NO.
YESNOCANCEL
Displays three buttons whose symbolic names are YES, NO and CANCEL.
Icon images:
ERROR
INFO
QUESTION
WARNING
谢谢你的反馈!