Monks I am again here hoping you can help me in my pursuit to learn Tk. I am creating a small program to create reports from various text files. The application first gives 3 different output types, then 2 different report types, and finally has a listbox of all the txt files in the directory. I am trying to pass all of this informatrion into a subroutine where I can start tracking the file changes. To test this I am just trying to get the value of the output, report_type, and listbox into the sub routine. The listbox valuse are fine, but the output type and report type is not changign with the radio buttons when I pass them. However outside of the subroutine the values do change with the radio buttons. Any suggestions on how to fix this? Here is the code.

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"; }


Any help you can offer would be very appreciated. Thanks!

-Prime

In reply to More Tk Help by PrimeLord

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.