for my applications I am looking for both a pure directory selection and a mixed fie and directory selection in PERL/Tk. There are a number of example programs available in the net, and I tried some of them, but I didn't find any which does exactly what I want to have. So I would like to ask you for help to find such an example program.
One of the examples for a directory selection tree I found and which I like is from Slaven Resic, located at http://www.perltk.org/files/dirtree.pl.txt:
use Tk; use Tk::DirTree; use Cwd; my $top = new MainWindow; $top->withdraw; my $t = $top->Toplevel; $t->title("Choose directory:"); my $ok = 0; my $f = $t->Frame->pack(-fill => "x", -side => "bottom"); my $curr_dir = 'd:'; #my $curr_dir = Cwd::cwd(); my $d; $d = $t->Scrolled('DirTree', -scrollbars => 'osoe', -width => 35, -height => 20, -selectmode => 'browse', -exportselection =>1, -browsecmd => sub { $curr_dir = shift }, -command => sub { $ok = 1; }, )->pack(-fill => "both", -expand => 1); $d->chdir($curr_dir); $f->Button(-text => 'Ok', -command => sub { $ok = 1 })->pack(-side => 'left'); $f->Button(-text => 'Cancel', -command => sub { $ok = 1 })->pack(-side => 'left'); $f->waitVariable(\$ok); if ($ok == 1) { warn "The resulting directory is '$curr_dir'\n"; } __END__
It does more or less what I want it to do, only that it displays the directory tree of one drive only, and I want to have a directory tree displaying all of the drives which are in use, both hard discs and rather temporary device like USB sticks. In an ideal situation the directory tree starts with a display of all drives (c:, d:, etc.) with the highest level of directorys, from which people then can click down to the folder they want to select.
With a slight modification of the above mentioned example program I almost get that: if I replace the line$d->chdir("c:"); $d->chdir("d:"); $d->chdir("e:");
I'll have all of the trees available, albeit the drive from which the program is started doesn't look exactly the way I described above, but opens to the directory in which the program is located.
I could live with this situation, but a more dynamic display through a program line(in which the @drives list contains all active drives, eg. estimated through an analysing function) didn't work, and I couldn't find the reason why.
So, once again, my questions:In reply to Directory and file selection with PERL/Tk by chanklaus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |