Author: Dan Shafer

# Directory Dialog

## Creating the Dialog

Create a Directory Dialog by calling dialog.directoryDialog with the two arguments shown in the following table.

Argument | Data type/notes
self | the window (background) that is the parent for the dialog
message | quoted string that provides a prompt to be displayed inside the dialog box
path | 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.

Example:
Above dialog was created with this line of code:
`result = dialog.directoryDialog(self, 'Choose a directory', '')`
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:

`result = dialog.directoryDialog(self, 'Choose a directory', 'C:\\Python23')
`

## Interacting With the Dialog

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.

Name of value | Description
accepted | True = user clicked OK False = user clicked Cancel
path | string containing the full path to the chosen directory

Example:
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."
accepted: True
path: C:\\pycode