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
15
17 The procedure tk_chooseDirectory pops up a dialog box for the user to
18 select a directory. The following option-value pairs are possible as
19 command line arguments:
20
21 -initialdir dirname
22 Specifies that the directories in directory should be displayed
23 when the dialog pops up. If this parameter is not specified,
24 then the directories in the current working directory are dis‐
25 played. If the parameter specifies a relative path, the return
26 value will convert the relative path to an absolute path. This
27 option may not always work on the Macintosh. This is not a bug.
28 Rather, the General Controls control panel on the Mac allows the
29 end user to override the application default directory.
30
31 -parent window
32 Makes window the logical parent of the dialog. The dialog is
33 displayed on top of its parent window.
34
35 -title titleString
36 Specifies a string to display as the title of the dialog box. If
37 this option is not specified, then a default title will be dis‐
38 played.
39
40 -mustexist boolean
41 Specifies whether the user may specify non-existent directories.
42 If this parameter is true, then the user may only select direc‐
43 tories that already exist. The default value is false.
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
54
56 tk_getOpenFile(n), tk_getSaveFile(n)
57
59 directory, selection, dialog, platform-specific
60
61
62
63Tk 8.3 tk_chooseDirectory(n)