| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# Perl/Tk version of Tix4.1.0/demos/samples/DirTree.tcl |
| 4 |
# |
| 5 |
# Chris Dean <[email protected]> |
| 6 |
|
| 7 |
use lib ".."; |
| 8 |
|
| 9 |
use strict; |
| 10 |
use Tk; |
| 11 |
use Tk::DirTree; |
| 12 |
use Cwd; |
| 13 |
|
| 14 |
my $top = new MainWindow( -title => "DirTree" ); |
| 15 |
main( $top ); |
| 16 |
MainLoop(); |
| 17 |
|
| 18 |
sub main { |
| 19 |
my( $top ) = @_; |
| 20 |
|
| 21 |
my $current_dir = getcwd; |
| 22 |
|
| 23 |
my $tree = $top->Scrolled( qw/DirTree |
| 24 |
-width 35 -height 30 |
| 25 |
-selectmode browse -exportselection 1 |
| 26 |
-scrollbars osoe/ ); |
| 27 |
|
| 28 |
my $lab = $top->Label( -text => "Installation Directory:" ); |
| 29 |
my $ent = $top->Entry( -textvariable => \$current_dir ); |
| 30 |
|
| 31 |
my $ok = $top->Button( qw/-text Ok -underline 0 -width 6/ ); |
| 32 |
my $cancel = $top->Button( qw/-text Cancel -underline 0 -width 6/ ); |
| 33 |
|
| 34 |
$tree->configure( -browsecmd => sub { $current_dir = shift } ); |
| 35 |
$tree->configure( -command => sub { do_it( $current_dir ) } ); |
| 36 |
$ok->configure( -command => sub { do_it( $current_dir ) } ); |
| 37 |
$cancel->configure( -command => sub { exit } ); |
| 38 |
|
| 39 |
$tree->pack( qw/-expand yes -fill both -padx 10 -pady 10 -side top/ ); |
| 40 |
$lab->pack( qw/-anchor w/ ); |
| 41 |
$ent->pack( qw/-fill x/ ); |
| 42 |
$ok->pack( qw/-side left -padx 10 -pady 10/ ); |
| 43 |
$cancel->pack( qw/-side right -padx 10 -pady 10/ ); |
| 44 |
} |
| 45 |
|
| 46 |
sub do_it { |
| 47 |
my( $dir ) = @_; |
| 48 |
print "Executing: $dir\n"; |
| 49 |
exit; |
| 50 |
} |
| 51 |
|
| 52 |
|