<!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>Directory Dialog</title> <meta name="generator" content="Namo WebEditor v5.0(Trial)"> </head> <body> <h1>Directory Dialog</h1> <img height="331" width="324" alt="Directory Dialog Sample" src="images/dialogsfig9.png"> <br> <br> <h2>Creating the Dialog</h2> Create a Directory Dialog by calling dialog.directoryDialog with the two 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"> <p>message</p> </td> <td valign="top"> <p>quoted string that provides a prompt to be displayed inside the dialog box </p> </td> </tr> <tr> <td valign="top"> path<br> </td> <td valign="top">quoted string providing the initial directory in which to open the dialog. Providing an invalid or non-existent directory places the user at the top level of the directory structure. If this string is empty, the directory dialog opens to the top-level directory. </td> </tr> </tbody> </table> <br> <b>Example:<br> <br> </b>Above dialog was created with this line of code:<br> <br> <code>result = dialog.directoryDialog(self, 'Choose a directory', '')</code><br> <br> Since the directory parameter is empty, the directory dialog opens at the top level of the directory structure as shown in the figure. To cause the directory dialog to open on a directory called, e.g., C:\PYTHON23, you would write: <p><code>result = dialog.directoryDialog(self, 'Choose a directory', 'C:\\Python23')<br> </code><br> </p> <h2>Interacting With the Dialog</h2> The directoryDialog 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">path<br> </td> <td valign="top">string containing the full path to the chosen directory<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 navigates to the C: drive and picks the directory called "pycode."<b><br> <br> </b>accepted: True<br> path: C:\\pycode<br> <br> <br> <br> <br> <br> <br> <br> <br> </body> </html>