Tk::FileSelect - a widget for choosing files
use Tk::FileSelect;
$FSref = $top->FileSelect(-directory => $start_dir); $top - a window reference, e.g. MainWindow->new $start_dir - the starting point for the FileSelect $file = $FSref->Show; Executes the fileselector until either a filename is accepted or the user hits Cancel. Returns the filename or the empty string, respectively, and unmaps the FileSelect. $FSref->configure(option => value[, ...]) Please see the Populate subroutine as the configuration list changes rapidly.
You can enter a starting directory in the directory entry. After hitting Return, the listboxes get updated. Double clicking on any directory shows you the respective contents. Single clicking on a file brings it into the file entry for further consideration, double clocking on a file pops down the file selector and calls the optional command with the complete path for the selected file. Hitting return in the file selector box or pressing the accept button will also work. *NOTE* the file selector box will only then get destroyed if the file name is not zero length. If you want yourself take care of it, change the if(length(.. in sub accept_file.
(Please see subroutine Populate for details, as these options change rapidly!)
Allow either file or directory names to be accepted.
For example:
$fs->configure(-verify => ['-d', [\&verify_code, $P1, $P2, ... $Pn]]);
ensures that the selected name is a directory. Further, if an element of the list is an array reference, the first element is a code reference to a subroutine and the remaining optional elements are it's parameters. The subroutine is called like this:
&verify_code($cd, $leaf, $P1, $P2, ... $Pn);
where $cd is the current directory, $leaf is a directory or file name, and $P1 .. $Pn are your optional parameters. The subroutine should return TRUE if success or FALSE if failure.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |