1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1">
<meta name="author" content="Dan Shafer">
<title>Message Dialog</title>
</head>
<body>
<h1>Message Dialog</h1>
<img height="119" width="185" alt="Message Dialog Sample"
src="images/dialogsfig8.png">
<br>
<br>
<h2>Creating the Dialog</h2>
Create a Message Dialog by calling dialog.messageDialog with
the three required and two optional arguments shown in the following table.<br>
<br>
<table cellpadding="2" cellspacing="2" border="1" width="80%">
<tbody>
<tr>
<td valign="top"><b>Argument</b><br>
</td>
<td valign="top"><b>Data type/notes</b><br>
</td>
</tr>
<tr>
<td valign="top">self<br>
</td>
<td valign="top">the window (background) that is the parent
for the dialog<br>
</td>
</tr>
<tr>
<td valign="top">message<br>
</td>
<td valign="top">quoted string displayed as the message in the dialog<br>
</td>
</tr>
<tr>
<td valign="top">title<br>
</td>
<td valign="top">quoted string displayed in title bar of
dialog<br>
</td>
</tr>
<tr>
<td valign="top">OPTIONAL icon<br>
</td>
<td valign="top">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.<br>
</td>
</tr>
<tr>
<td valign="top">OPTIONAL buttons<br>
</td>
<td valign="top">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.<br>
<br><b>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).</b>
</td>
</tr>
</tbody>
</table>
<br>
<b>Example:<br>
<br>
</b>Above dialog was created with this line of code:<br>
<br>
<code>result = dialog.messageDialog(self, 'a message', 'a title')</code><br>
<br>
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:<br>
<br>
<table cellpadding="2" cellspacing="2" border="1" width="80%">
<tbody>
<tr>
<td valign="top"><b>Constant</b><br>
</td>
<td valign="top"><b>Description of Icon</b><br>
</td>
</tr>
<tr>
<td valign="top">wx.ICON_EXCLAMATION<br>
</td>
<td valign="top">Exclamation point<br>
</td>
</tr>
<tr>
<td valign="top">wx.ICON_HAND <br>
</td>
<td valign="top">Hand, or error, icon<br>
</td>
</tr>
<tr>
<td valign="top">wx.ICON_ERROR<br>
</td>
<td valign="top">Same as ICON_HAND<br>
</td>
</tr>
<tr>
<td valign="top">wx.ICON_QUESTION<br>
</td>
<td valign="top">Question mark<br>
</td>
</tr>
<tr>
<td valign="top">wx.ICON_INFORMATION <br>
</td>
<td valign="top">Small "i" icon, the default icon<br>
</td>
</tr>
</tbody>
</table>
<br>
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.<br>
<br>
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:<br>
<br>
<table cellpadding="2" cellspacing="2" border="1" width="80%">
<tbody>
<tr>
<td valign="top"><b>Constant</b><br>
</td>
<td valign="top"><b>Button Labels</b><br>
</td>
</tr>
<tr>
<td valign="top">wx.OK<br>
</td>
<td valign="top">OK Button<br>
</td>
</tr>
<tr>
<td valign="top">wx.CANCEL<br>
</td>
<td valign="top">Cancel Button<br>
</td>
</tr>
<tr>
<td valign="top">wx.YES_NO<br>
</td>
<td valign="top">Two buttons, one labeled "Yes" and the other labeled
"No"<br>
</td>
</tr>
<tr>
<td valign="top">wx.YES_DEFAULT<br>
</td>
<td valign="top">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.<br>
</td>
</tr>
<tr>
<td valign="top">wx.NO_DEFAULT<br>
</td>
<td valign="top">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.<br>
</td>
</tr>
</tbody>
</table>
<br>
<h2>Interacting With the Dialog</h2>
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.<br>
<br>
<table cellpadding="2" cellspacing="2" border="1" width="80%">
<tbody>
<tr>
<td valign="top"><b>Name of value</b><br>
</td>
<td valign="top"><b>Description</b><br>
</td>
</tr>
<tr>
<td valign="top">accepted<br>
</td>
<td valign="top">True = user clicked OK<br>
False = user clicked Cancel<br>
</td>
</tr>
<tr>
<td valign="top">returnedString<br>
</td>
<td valign="top">string containing 'Ok' or 'Cancel' reflecting
which button the user clicked to dismiss the Message dialog<br>
</td>
</tr>
</tbody>
</table>
<br>
<b>Example:<br>
<br>
</b> The sample dialog shown at the top of this page returns the
following results:<b><br>
<br>
</b>accepted: True<br>
returnedString: Ok<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>
|