NAME
Tk::PathEntry - Entry widget for selecting paths with completion
SYNOPSIS
use Tk::PathEntry;
my $pe = $mw->PathEntry(-textvariable => \$path)->pack;
$pe->bind("<Return>" => sub { warn "The pathname is $path\n" });
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 standardglob
function.
METHODS
- Finish
-
This will popdown the window with the completion choices. It is advisable to bind the Return key to call this method. The popdown is done automatically when the widget loses the input 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);
$e->bind("<Return>" => sub { $e->Finish });
1;
') {
$e = $mw->Entry(-textvariable => \$file);
}
$e->pack;
SEE ALSO
Tk::PathEntry::Dialog (3), Tk::Entry (3), tcsh (1), bash (1).
AUTHOR
Slaven Rezic <srezic@cpan.org>
COPYRIGHT
Copyright (c) 2001 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.