pops up a dialog box for the user to select a directory. ---- http://purl.org/tcl/home/man/tcl8.4/TkCmd/chooseDirectory.htm ---- '''SYNOPSIS''' '''tk_chooseDirectory''' ''?option value ...?'' '''DESCRIPTION''' The procedure '''tk_chooseDirectory''' pops up a dialog box for the user to select a directory. The following ''option-value'' pairs are possible as command line arguments: '''-initialdir''' ''dirname'' Specifies that the directories in ''directory'' should be displayed when the dialog pops up. If this parameter is not specified, then the directories in the current working directory are displayed. If the parameter specifies a relative path, the return value will convert the relative path to an absolute path. This option may not always work on the Macintosh. This is not a bug. Rather, the ''General Controls'' control panel on the Mac allows the end user to override the application default directory. '''-parent''' ''window'' Makes ''window'' the logical parent of the dialog. The dialog is displayed on top of its parent window. '''-title''' ''titleString'' Specifies a string to display as the title of the dialog box. If this option is not specified, then a default title will be displayed. '''-mustexist''' ''boolean'' Specifies whether the user may specify non-existant directories. If this parameter is true, then the user may only select directories that already exist. The default value is ''false''. '''SEE ALSO''' [tk_getOpenFile], [tk_getSaveFile] ---- See also: [chooseDirectory] - [select] ---- No help from [TclHelp] on this (it's not in the index) - but we can get some help from Tk itself, by making a deliberate mistake in an interactive wish: % tk_chooseDirectory -help bad option "-help": must be -initialdir, -mustexist, -parent, or -title Pops up a directory chooser (toplevel window). On Windows, using an old API - tree widget for a drive, and a drive selector below. On Unix (Tk 8.3), a selection widget (without drive selector). Pauses execution until 'OK' or 'Cancel' have been selected. Returns the chosen pathname with canonical separators (slashes), or an empty string if canceled. Will on Windows not accept selection of mystic pathnames like C:\TEMP\axp426\{6F6549EC-8E14-11D3-BF1A-0060086F667D} ---- See http://www.purl.org/net/TclTkProgRef for [Chris Nelson]'s '''tk_chooseDirectory''' written in pure Tcl. A little more of a note on this util script: On Microsoft Windows 95 the '''tk_chooseDirectory''' fails. Apparently, a helper file or system dll is broken. Therefore, this script comes in real handy. It should also be noted that the '''tk_chooseDirectory''' function that comes with tcl/tk distribution is Windows only. So this file will be very helpful on your *nix or other platform computers. Another consideration should be taken with Windows 95. This script does not handle mapped drives. You may have to add that functionality yourself. Note: '''tk_chooseDirectory''' was added to the UNIX Tk distribution in, I think, 8.3; it is an adaptation of the script in my site. -- [CLN] ---- Are there issues when choosing new vs existing directories? Does this routine support the case where one wants to select a subdirectory of a not-yet existing directory? ---- [MG] Jan 21 2005 - In many apps on Windows that use a dialog similar to tk_chooseDirectory's, they have a button to create a new directory, when that's allowed. Apart from the addition of that button, though, it looks identical to tk_chooseDirectory; is this the same dialog from the MS Windows API? And if so, would it be possible to alter tk_chooseDirectory so that it shows the 'New' button, when -mustexist is false? ---- [SEH] -- 1/21/05 -- Is there a way to call tk_chooseDirectory explicitly on Windows in a manner equivalent to [[::tk::dialog::file::]] for tk_getOpenFile? ---- [JJS] 20150207 There seems to be an inconsistency between how -initialdir is documented to work and how it actually works, at least with Tclkit 8.5.17 under Windows 7. The man page says it "Specifies that the directories in ''directory'' should be displayed when the dialog pops up", but it actually displays ''directory'' and its ''siblings''; you have to open ''directory'' to see its contents. And then it has the annoying behavior that when you open a directory, it positions it at the lowest point in the window so that you can't actually see its contents without scrolling. This means that digging for deeply buried directory means "open, scroll, open, scroll..." ''ad nauseam''. Are these behaviors normal? <> Arts and Crafts of Tcl-Tk Programming | Command | Dialog | File | Tk syntax help