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:
Create a message window with an application-specified message, an icon
and a set of buttons.
Each of the buttons in the message window is identified by a unique symbolic name (see the type options).
The following options are supported:
command
Specifies the function to invoke when the user closes the dialog.
The name of the button clicked by the user to close the dialog is
passed as argument.
This is only available on macOS.
default
Gives the symbolic name of the default button
for this message window (OK, CANCEL, and so on).
If this option is not specified, the first button in the dialog will
be made the default.
detail
Specifies an auxiliary message to the main message given by the
message option.
The message detail will be presented beneath the main message and,
where supported by the OS, in a less emphasized font than the main
message.
icon
Specifies an icon to display.
If this option is not specified, then the INFO icon will be
displayed.
message
Specifies the message to display in this message box.
The default value is an empty string.
parent
Makes the specified window the logical parent of the message box.
The message box is displayed on top of its parent window.
title
Specifies a string to display as the title of the message box.
This option is ignored on macOS, where platform guidelines forbid
the use of a title on this kind of dialog.
Display a message window and wait for the user to select one of the buttons. Then return the symbolic name of the selected button.
Keyword arguments can override options specified in the constructor.
The Python Software Foundation is a non-profit corporation.
Please donate.
Last updated on Nov 13, 2026 (01:32 UTC).
Found a bug?
Created using Sphinx 9.1.1.
You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.