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,
23 then the directories in the current working directory are dis‐
24 played. If the parameter specifies a relative path, the return
25 value will convert the relative path to an absolute path.
26
27 -mustexist boolean
28 Specifies whether the user may specify non-existent directories.
29 If this parameter is true, then the user may only select direc‐
30 tories that already exist. The default value is false.
31
32 -parent window
33 Makes window the logical parent of the dialog. The dialog is
34 displayed on top of its parent window. On Mac OS X, this turns
35 the file dialog into a sheet attached to the parent window.
36
37 -title titleString
38 Specifies a string to display as the title of the dialog box. If
39 this option is not specified, then a default title will be dis‐
40 played.
41
43 set dir [tk_chooseDirectory \
44 -initialdir ~ -title "Choose a directory"]
45 if {$dir eq ""} {
46 label .l -text "No directory selected"
47 } else {
48 label .l -text "Selected $dir"
49 }
50
51
53 tk_getOpenFile(n), tk_getSaveFile(n)
54
56 directory, selection, dialog, platform-specific
57
58
59
60Tk 8.3 tk_chooseDirectory(n)