Here's an example of a listbox with directories only, and when you click on an item, it will show information in the text widget.

#!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"); }
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.

This is just a rudimentary script, but it should be less confusing, and hopefully meets your requirements.

--
.dave.


In reply to Re: Perl::Tk help to startup. by hiseldl
in thread Perl::Tk help to startup. by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.