PrimeLord has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Tk; # Defaults my $version = "change_tracker 0.5 beta"; my $output = "HTML"; my $report_type = "SHORT"; # Main Window my $mw = MainWindow->new; $mw->title("$version"); # Frames my $label1_frame = $mw->Frame; my $outputlist_frame = $mw->Frame; my $label2_frame = $mw->Frame; my $typelist_frame = $mw->Frame; my $label3_frame = $mw->Frame; my $files_frame = $mw->Frame; my $exit_frame = $mw->Frame; # Output Lablel $label1_frame->Label(-text => "Type of Output")->pack; # Output List for ("HTML", "CSV", "TEXT") { $outputlist_frame->Radiobutton(-text => $_, -value => $_, -variable => \$output)->pack(-side => 'left'); } # Report Type Label $label2_frame->Label(-text => "Report Type")->pack; # Report Type List for ("SHORT", "LONG") { $typelist_frame->Radiobutton(-text => $_, -value => $_, -variable => \$report_type)->pack(-side => 'left'); } # File Listing Label $label3_frame->Label(-text => "Select Files to Track")->pack(-side => +'left'); # File Listing Listbox my @files; opendir DIR, "." or die "$!"; @files = sort grep /\.txt$/, readdir DIR; closedir DIR; my $listbox = $files_frame->Scrolled("Listbox", -scrollbars => "oe", -selectmode => "extended")->pack; $listbox->insert('end', @files); # Track Changes $exit_frame->Button(-text => "Track", -command => [ \&track_changes, ($listbox, $output, $report_typ +e) ])->pack; # Exit Button $exit_frame->Button(-text => "Exit", -command => sub { exit; })->pack; # Pack Frames $label1_frame->pack(-side => 'top', -fill => 'y'); $outputlist_frame->pack(-side => 'top', -fill => 'y'); $label2_frame->pack(-side => 'top', -fill => 'y'); $typelist_frame->pack(-side => 'top', -fill => 'y'); $label3_frame->pack(-side => 'top', -fill => 'y'); $files_frame->pack(-side => 'top', -fill => 'y'); $exit_frame->pack(-side => 'top', -fill => 'y'); # Main Loop MainLoop; sub track_changes { my ($listbox, $output, $report_type) = @_; my @files = $listbox->curselection; for (@files) { my $file = $listbox->get($_); print "$file\n"; } print "$output\n"; print "$report_type\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: More Tk Help
by tall_man (Parson) on Jan 11, 2005 at 00:00 UTC | |
by jdporter (Paladin) on Jan 11, 2005 at 14:19 UTC |