NAME

Tk::PathEntry - Entry widget for selecting paths with completion

SYNOPSIS

    use Tk::PathEntry;
    my $pe = $mw->PathEntry
                     (-textvariable => \$path,
		      -selectcmd => sub { warn "The pathname is $path\n" },
		     )->pack;

DESCRIPTION

This is an alternative to classic file selection dialogs. It works more like the file completion in modern shells like tcsh or bash.

With the Tab key, you can force the completion of the current path. If there are more choices, a window is popping up with these choices. With the Meta-Backspace or Alt-Backspace key, the last path component will be deleted.

OPTIONS

Tk::PathEntry supports all standard Tk::Entry options except -vcmd and -validate (these are used internally in PathEntry). The additional options are:

-initialdir

Set the initial path to the value. Alias: -initialfile. You can also use a pre-filled -textvariable to set the initial path.

-separator

The character used as the path component separator. For Unix, this is "/".

-isdircmd

Can be used to set another directory recognizing subroutine. The directory name is passed as second parameter. Alias: -isdirectorycommand. The default is a subroutine using -d.

-choicescmd

Can be used to set another globbing subroutine. The current pathname is passed as second parameter. Alias: -choicescommand. The default is a subroutine using the standard glob function.

-selectcmd

This will be called if a path is selected, either by hitting the Return key or by clicking on the choice listbox. Alias: -selectcommand.

-cancelcmd

This will be called if the Escape key is pressed. Alias: -cancelcommand.

METHODS

Finish

This will popdown the window with the completion choices. It is called automatically if the user selects an entry from the listbox, hits the Return or Escape key or the widget loses the focus.

EXAMPLES

If you want to not require from your users to install Tk::PathEntry, you can use the following code snippet to create either a PathEntry or an Entry, depending on what is installed:

my $e;
if (!eval '
    use Tk::PathEntry;
    $e = $mw->PathEntry(-textvariable => \$file,
                        -selectcmd => sub { $e->Finish },
                       );
    1;
') {
    $e = $mw->Entry(-textvariable => \$file);
}
$e->pack;

NOTES

Since Tk::PathEntry version 2.17, it is not recommended to bind the Return key directly. Use the -selectcmd option instead.

SEE ALSO

Tk::PathEntry::Dialog (3), Tk::Entry (3), tcsh (1), bash (1).

AUTHOR

Slaven Rezic <srezic@cpan.org>

COPYRIGHT

Copyright (c) 2001,2002 Slaven Rezic. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.