1tk_chooseDirectory(n) Tk Built-In Commands tk_chooseDirectory(n)
2
3
4
5______________________________________________________________________________
6
8 tk_chooseDirectory - pops up a dialog box for the user to select a
9 directory.
10
12 tk_chooseDirectory ?option value ...?
13______________________________________________________________________________
14
16 The procedure tk_chooseDirectory pops up a dialog box for the user to
17 select a directory. The following option-value pairs are possible as
18 command line arguments:
19
20 -initialdir dirname
21 Specifies that the directories in directory should be displayed
22 when the dialog pops up. If this parameter is not specified, the
23 initial directory defaults to the current working directory on
24 non-Windows systems and on Windows systems prior to Vista. On
25 Vista and later systems, the initial directory defaults to the
26 last user-selected directory for the application. If the parame‐
27 ter specifies a relative path, the return value will convert the
28 relative path to an absolute path.
29
30 -mustexist boolean
31 Specifies whether the user may specify non-existent directories.
32 If this parameter is true, then the user may only select direc‐
33 tories that already exist. The default value is false.
34
35 -parent window
36 Makes window the logical parent of the dialog. The dialog is
37 displayed on top of its parent window. On Mac OS X, this turns
38 the file dialog into a sheet attached to the parent window.
39
40 -title titleString
41 Specifies a string to display as the title of the dialog box. If
42 this option is not specified, then a default title will be dis‐
43 played.
44
46 set dir [tk_chooseDirectory \
47 -initialdir ~ -title "Choose a directory"]
48 if {$dir eq ""} {
49 label .l -text "No directory selected"
50 } else {
51 label .l -text "Selected $dir"
52 }
53
55 tk_getOpenFile(n), tk_getSaveFile(n)
56
58 directory, selection, dialog, platform-specific
59
60
61
62Tk 8.3 tk_chooseDirectory(n)