#!/usr/bin/perl use File::stat; use Tk; use Tk::MListbox; ## Create main perl/tk window. my $mw = MainWindow->new; ## Create the MListbox widget. ## Specify alternative comparison routine for integers and date. ## frame, but since the "Show All" button references $ml, we have to create ## it now. my %red = qw(-bg red -fg white); my %green = qw(-bg green -fg white); my %white = qw(-fg black); my $ml = $mw->Scrolled('MListbox', -scrollbars => 'osoe', -background => 'white', -foreground => 'blue', -textwidth => 10, -highlightthickness => 2, -width => 0, -selectmode => 'browse', -bd=>2, -relief=>'sunken', -columns=>[ [qw/-text Mode -textwidth 10/, %red], [qw/-text NLink -textwidth 5/, %green, -comparecmd => sub {$_[0] <=> $_[1]}], [qw/-text UID/, %white], [qw/-text GID/, %green], [qw/-text Size/,%red, -comparecmd => sub {$_[0] <=> $_[1]}], [qw/-text Mtime/, %green, -comparecmd => \&compareDate], [qw/-text Name/, %white] ]); ## Put the exit button and the "Show All" button in ## a separate frame. my $f = $mw->Frame( -bd=>2, -relief=>'groove' )->pack(qw/-anchor w -expand 0 -fill x/); $f->Button( -text=>'Exit', -command => sub{exit} )->pack(qw/-side right -anchor e/); $f->Button( -text=>'Show All', -command=>sub { foreach ($ml->columnGet(0,'end')) { $ml->columnShow($_); } })->pack(qw/-side left -anchor w/); # Put the MListbox widget on the bottom of the main window. $ml->pack(-expand=>1, -fill=>'both', -anchor=>'w'); # Double clicking any of the data rows calls openFileOrDir() # (But only directories are handled for now...) $ml->bindRows("", \&openFileOrDir); $ml->bindRows("