Version 0 of tk_chooseDirectory

Updated 2001-06-07 08:26:53

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


Tk syntax help - Arts and crafts of Tcl-Tk programming