Author: Dan Shafer

# Message Dialog

## Creating the Dialog

Create a Message Dialog by calling dialog.messageDialog with the three required and two optional arguments shown in the following table.

Argument | Data type/notes
self | the window (background) that is the parent for the dialog
message | quoted string displayed as the message in the dialog
title | quoted string displayed in title bar of dialog
OPTIONAL icon | You may optionally include one of the defined wxPython constants defining an icon to be displayed in the message dialog. By default, PythonCard displays the "info" icon shown in the figure above. See below for details.
OPTIONAL buttons | You may optionally include one of the defined exPython constants defining one or more button names to be displayed in the Message dialog. By default, PythonCard displays the "OK" and "Cancel" buttons shown in the figure above. See below for details. Note that as of PythonCard 0.8 the fourth and fifth args have been combined, so you should use | (binary or) to join them (e.g. wx.ICON_EXCLAMATION | wx.OK).

Example:
Above dialog was created with this line of code:
`result = dialog.messageDialog(self, 'a message', 'a title')`
To add an icon other than the default "info" icon to the Message Dialog, provide the fourth argument, which can be any of the values shown in the following table:

Constant | Description of Icon
wx.ICON_EXCLAMATION | Exclamation point
wx.ICON_HAND | Hand, or error, icon
wx.ICON_ERROR | Same as ICON_HAND
wx.ICON_QUESTION | Question mark
wx.ICON_INFORMATION | Small "i" icon, the default icon

Note that there are user interface guidelines for the appropriate use of these icons. It is generally a good idea to use them in the standard ways users expect to encounter them.
You can also cause the Message Dialog to display buttons labeled other than "OK" and "Cancel" by providing one of the constants in the following table as the optional fifth argument to the dialog.messageDialog method:

Constant | Button Labels
wx.OK | OK Button
wx.CANCEL | Cancel Button
wx.YES_NO | Two buttons, one labeled "Yes" and the other labeled "No"
wx.YES_DEFAULT | If you supply BUTTON_YES_NO as the button constant, you can optionally include this constant to cause the "Yes" button to be the default button. Since "Yes" is always the default button unless you change it, this constant is probably not of much use.
wx.NO_DEFAULT | If you supply wx.YES_NO as the button constant, you can optionally include this constant to cause the "No" button to be the default button.

## Interacting With the Dialog

The messageDialog component returns two values, stored as elements of the Python dictionary called "results" returned by all PythonCard dialogs. These results are as shown in the following table.

Name of value | Description
accepted | True = user clicked OK False = user clicked Cancel
returnedString | string containing 'Ok' or 'Cancel' reflecting which button the user clicked to dismiss the Message dialog

Example:
The sample dialog shown at the top of this page returns the following results:
accepted: True
returnedString: Ok