Displaying the directory dialog

The tk_chooseDirectory command displays a dialog window that allows the end user to select a directory, as the name implies. The return value is the absolute directory path selected or an empty string (if the Cancel button is clicked).

The syntax is as follows:

	tk_chooseDirectory option value …

The tk_chooseDirectory command accepts one or more option value pairs as detailed below. If no option value pairs are provided, the command will display the default values for the dialog.

Option

Interpretation

-initialdir directory

Sets the initial directory to display. If not set, the current working directory will be displayed.

-mustexist boolean

Specifies if the user may specify a non-existing directory.

Get Tcl/Tk 8.5 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.