<!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>Text Entry Dialog</title> </head> <body> <h1>Text Entry Dialog</h1> <img height="134" width="336" alt="Text Entry Dialog Sample" src="images/dialogsfig11.png"> <br> <br> <h2>Creating the Dialog</h2> Create a Text Entry Dialog by calling dialog.textEntryDialog with the four required and one 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 to be displayed inside the Text Entry Dialog to prompt the user's reply<br> </td> </tr> <tr> <td valign="top">title<br> </td> <td valign="top">quoted string to be displayed in the title bar of the Text Entry Dialog<br> </td> </tr> <tr> <td valign="top">defaultText<br> </td> <td valign="top">quoted string to be displayed in the text field in the Text Entry Dialog containing the response to be used if the user doesn't change it. May be an empty string.<br> </td> </tr> <tr> <td valign="top">OPTIONAL field type<br> </td> <td valign="top">The optional fifth argument to the constructor for this dialog can contain one of two constants that affect the display of the text field. If this argument is wx.TE_PASSWORD, asterisks or bullets replace the default text (if any) as well as the user's typing in the field. If this argument is wx.TE_MULTILINE, the field expands to accommodate multiple lines of entry data.<br> </td> </tr> </tbody> </table> <br> <b>Example:<br> <br> </b>Above dialog was created with this line of code:<br> <br> <code> result = dialog.textEntryDialog(self, <br> 'What is your favorite language?',<br> 'A window title', <br> 'Python')</code><br> <h2>Interacting With the Dialog</h2> The textEntryDialog component returns three 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 the label of the button the user clicked<br> </td> </tr> <tr> <td valign="top">text<br> </td> <td valign="top">String containing the text in the text entry field of the dialog at the time the user clicked the button or closed the 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 if the user doesn't change anything and clicks the "OK" button:<b><br> <br> </b>accepted: True<br> returnedString: Ok<br> text: Python<br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> </body> </html>