.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "chooseDirectory 3" .TH chooseDirectory 3 2023-07-25 "perl v5.38.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Tk::chooseDirectory \- pops up a dialog box for the user to select a directory. .SH SYNOPSIS .IX Header "SYNOPSIS" \&\fR\f(CI$widget\fR\fI\fR\->\fBchooseDirectory\fR( ?\fIoption value ...\fR? ); .SH DESCRIPTION .IX Header "DESCRIPTION" The method \fBchooseDirectory\fR is implemented as a perl wrapper on the core tk "command" \fBtk_chooseDirectory\fR, and \fR\f(CI$widget\fR\fI\fR is passed as the argument to the hidden \fB\-parent\fR option. .PP The \fBchooseDirectory\fR method pops up a dialog box for the user to select a directory. The following \fIoption-value\fR pairs are possible as command line arguments: .IP "\fB\-initialdir\fR \fIdirname\fR" 4 .IX Item "-initialdir dirname" Specifies that the directories in \fIdirectory\fR should be displayed when the dialog pops up. If this parameter is not specified, then the directories in the current working directory are displayed. If the parameter specifies a relative path, the return value will convert the relative path to an absolute path. This option may not always work on the Macintosh. This is not a bug. Rather, the \fIGeneral Controls\fR control panel on the Mac allows the end user to override the application default directory. .ie n .IP "\fB\-parent\fR $widget" 4 .el .IP "\fB\-parent\fR \f(CW$widget\fR" 4 .IX Item "-parent $widget" Makes \f(CW$widget\fR the logical parent of the dialog. The dialog is displayed on top of its parent window. .IP "\fB\-title\fR \fItitleString\fR" 4 .IX Item "-title titleString" Specifies a string to display as the title of the dialog box. If this option is not specified, then a default title will be displayed. .IP "\fB\-mustexist\fR \fIboolean\fR" 4 .IX Item "-mustexist boolean" Specifies whether the user may specify non-existant directories. If this parameter is true, then the user may only select directories that already exist. The default value is \fIfalse\fR. .SH CAVEATS .IX Header "CAVEATS" Perl does not have a concept of encoded filesystems yet. This means that operations on filenames like \f(CW\*(C`opendir\*(C'\fR and \f(CW\*(C`open\*(C'\fR still use byte semantics. Tk however uses character semantics internally, which means that you can get filenames with the UTF\-8 flag set in functions like \f(CW\*(C`chooseDirectory\*(C'\fR, \f(CW\*(C`getOpenFile\*(C'\fR and similar. It's the user's responsibility to determine the encoding of the underlying filesystem and convert the result into bytes, e.g. .PP .Vb 6 \& use Encode; \& ... \& my $dir = $mw\->chooseDirectory; \& $dir = encode("windows\-1252", $dir); \& opendir DIR, $dir or die $!; \& ... .Ve .PP See also "When Unicode Does Not Happen" in perlunicode and "Unicode in Filenames" in perltodo. .SH EXAMPLE .IX Header "EXAMPLE" .Vb 7 \& my $dir = $mw\->chooseDirectory(\-initialdir => \*(Aq~\*(Aq, \& \-title => \*(AqChoose a directory\*(Aq); \& if (!defined $dir) { \& warn \*(AqNo directory selected\*(Aq; \& } else { \& warn "Selected $dir"; \& } .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Tk::getOpenFile, Tk::getOpenFile .SH KEYWORDS .IX Header "KEYWORDS" directory selection dialog