in reply to Perl::Tk help to startup.
The OnShowFileAttr method is where you will want to add your file/dir stat information retrieval. The $ListBox->get($index) will contain the item selected.#!perl -w use strict; use File::Find; use Tk; use Tk::Frame; use Tk::Text; use Tk::Scrollbar; use Tk::Adjuster; # Main Window my $mw = new MainWindow; $mw->geometry('400x300'); # Main Frame my $lf = $mw->Frame; # Left Frame; my $aj = $mw->Adjuster(-widget => $lf, -side => 'left'); my $rf = $mw->Frame; # Right Frame; # Args my $path = $ARGV[0]; # path passed in on the cmd line # create list of directories my %dirs; find(sub {$dirs{$File::Find::dir}++;}, $path); my($ListBox) = $lf->Scrolled('Listbox', -height => '0', -width => '0', -scrollbars => 'e', ); my($OutputText) = $rf->Scrolled('Text', -height => '1', -width => '1', -scrollbars => 'osoe', ); # Load dir names into the listbox $ListBox->insert('end', keys %dirs); # Left mouse button calls display sub $ListBox->bind('<ButtonRelease-1>', sub { OnShowFileAttr(); } ); # Pack everything $lf->pack(qw/-side left -fill y/); $aj->pack(qw/-side left -fill y/); $rf->pack(qw/-side right -fill both -expand 1/); $ListBox ->pack(qw/-side left -fill both -expand 1/); $OutputText->pack(qw/-side bottom -fill both -expand 1/); # Start the main event loop MainLoop; exit 0; sub OnShowFileAttr { my ($index) = $ListBox->curselection(); my $filestats = join ":", lstat($ListBox->get($index)); $OutputText->insert('end', $filestats."\n"); }
This is just a rudimentary script, but it should be less confusing, and hopefully meets your requirements.
--
.dave.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Perl::Tk help to startup.
by blackadder (Hermit) on Jul 16, 2002 at 16:55 UTC |