FileSave - a widget for choosing files
use Tk::FileSave; $FSref = $top->FileSave(-directory => $start_dir); $top - a window reference, e.g. MainWindow->new $start_dir - the starting point for the FileSave $FSref = $top->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 FileSave. $FSref = $top->configure(option => value[, ...]) At the moment, only one option is taken care of: -directory changes the starting directory for the Fileselector to the one given as value.
This Module pops up a Fileselector box, with a directory entry on top, a list of directories in the current directory, a list of files in the current directory, an entry for entering/modifying a file name, an accept button and a cancel button. 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.
Based on original FileSelect by Klaus Lichtenwalder, Lichtenwalder@ACM.org, Datapat GmbH, Munich, April 22, 1995 adapted by Frederick L. Wagner, firstname.lastname@example.org, Texas Instruments Incorporated, Dallas, 21Jun95
950621 -- The following changes were made: 1: Rewrote Tk stuff to take advantage of new Compound widget module, so FileSelect is now composed of 2 LabEntry and 2 ScrlListbox2 subwidgets. 2: Moved entry labels (from to the left of) to above the entry fields. 3: Caller is now able to control these aspects of widget, in both FileSelect (new) and configure : Option Controls Default -------------------- ----------------------------------- ------------ -directory initial directory `pwd` -selectmode mode of Files listbox browse -dir_entry_label label over directory filter entry "Filter" -dir_list_label label over directory listbox "Directories" -file_entry_label label over file entry "File" -file_list_label label over file listbox "Files" -height listbox height 20 -width listbox width 20 4: I changed from Double-Button-1 to Button-1 in the Files listbox, to work with multiple mode in addition to browse mode. I also made some name changes (LastPath --> saved_path, ...). 5: The show method is not yet updated. 6: The topLevel stuff is not done yet. I took it out while I toy with the idea of FileSelect as a subwidget. Then the 'normal' topLevel thing with Buttons along the bottom could be build on top of it. By request of Henry Katz <email@example.com>, I added the functionality of using the Directory entry as a filter. So, if you want to only see the *.c files, you add a .c (the *'s already there :) and hit return.