1chooseDirectory(3)    User Contributed Perl Documentation   chooseDirectory(3)
2
3
4

NAME

6       chooseDirectory - pops up a dialog box for the user to select a
7       directory.
8

SYNOPSIS

10       $widget->chooseDirectory( ?option value ...? );
11

DESCRIPTION

13       The method chooseDirectory is implemented as a perl wrapper on the core
14       tk "command" tk_chooseDirectory, and $widget is passed as the argument
15       to the hidden -parent option.
16
17       The chooseDirectory method pops up a dialog box for the user to select
18       a directory. The following option-value pairs are possible as command
19       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, then
24           the directories in the current working directory are displayed. If
25           the parameter specifies a relative path, the return value will
26           convert the relative path to an absolute path.  This option may not
27           always work on the Macintosh.  This is not a bug. Rather, the
28           General Controls control panel on the Mac allows the end user to
29           override the application default directory.
30
31       -parent $widget
32           Makes $widget 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
38           displayed.
39
40       -mustexist boolean
41           Specifies whether the user may specify non-existant directories.
42           If this parameter is true, then the user may only select
43           directories that already exist.  The default value is false.
44

CAVEATS

46       Perl does not have a concept of encoded filesystems yet. This means
47       that operations on filenames like "opendir" and "open" still use byte
48       semantics. Tk however uses character semantics internally, which means
49       that you can get filenames with the UTF-8 flag set in functions like
50       "chooseDirectory", "getOpenFile" and similar. It's the user's
51       responsibility to determine the encoding of the underlying filesystem
52       and convert the result into bytes, e.g.
53
54           use Encode;
55           ...
56           my $dir = $mw->chooseDirectory;
57           $dir = encode("windows-1252", $dir);
58           opendir DIR, $dir or die $!;
59           ...
60
61       See also "When Unicode Does Not Happen" in perlunicode and "Unicode in
62       Filenames" in perltodo.
63

EXAMPLE

65           my $dir = $mw->chooseDirectory(-initialdir => '~',
66                                          -title => 'Choose a directory');
67           if (!defined $dir) {
68               warn 'No directory selected';
69           } else {
70               warn "Selected $dir";
71           }
72

SEE ALSO

74       Tk::getOpenFile, Tk::getOpenFile
75

KEYWORDS

77       directory selection dialog
78
79
80
81perl v5.16.3                      2014-06-10                chooseDirectory(3)
Impressum