Thanks for your help. I have been trying to figure this out all weekend and got a little frustrated.

Forgive me everyone.

Here is a little snippet that everyone can run to see my problem. The problem again is when I click 1 checkbutton they all get selected.

use strict; use warnings; use Tk; use Tk::Table; our $MW = MainWindow->new(%{$BPP::BPPDEFAULTS::MYDEFAULTS{MAINWINDOW}} +); $MW->geometry('800x700+0+0'); my $tableframe = $MW->Frame(-background=>'white' )->pack(-side=>'top', -fill=>'both', -pady=>20); my $bill_table = $tableframe->Table(-rows=>2, -columns=>3, -background=>'pink', -scrollbars=>'e' )->pack(-fill=>'both', -side=>'top', -anchor=>'s'); my @foo = qw/ Apple Oranges Pears/; my $x = 1; my $checkbox; my $checkboxvalue = 0; foreach my $f (@foo) { $checkbox = $bill_table->Checkbutton(-variable=>\$checkboxvalue); $bill_table->put($x,0, $checkbox); $bill_table->put($x,1, $f); $bill_table->Button(-text=>'Submit', -command=>sub{print $f} )->pack; $x++; }#end foreach loop MainLoop;

So to distinguish them I tried putting the -variable value in an array. This fixes the selection issue but then that -variable value is not being set when I click on the checkbutton. I get this error: Use of uninitialized value in numeric eq (==)

use strict; use warnings; use Tk; use Tk::Table; our $MW = MainWindow->new(%{$BPP::BPPDEFAULTS::MYDEFAULTS{MAINWINDOW}} +); $MW->geometry('800x700+0+0'); my $tableframe = $MW->Frame(-background=>'white' )->pack(-side=>'top', -fill=>'both', -pady=>20); my $bill_table = $tableframe->Table(-rows=>2, -columns=>3, -background=>'pink', -scrollbars=>'e' )->pack(-fill=>'both', -side=>'top', -anchor=>'s'); my @foo = qw/ Apple Oranges Pears/; my $x = 1; my $t=0; my $checkbox; my @checkboxvalue; foreach my $f (@foo) { $checkbox = $bill_table->Checkbutton(-variable=>\$checkboxvalue[$t]); $bill_table->put($x,0, $checkbox); $bill_table->put($x,1, $f); $bill_table->Button(-text=>'Submit', -command=>sub{if ($checkboxvalue[$t] ==1){prin +t $f}} )->pack; $x++; $t++; }#end foreach loop MainLoop;

I hope this makes my problem clearer.
================================================

I need a Checkbutton and a Submit button on each line becuase there will be distinct information I need to change on each line. When the Checkbutton is selected, the information in that line is editable and the Submit button submits those changes for that line only.

I also need a reference to the checkbutton in order to PUT it in the table.

$checkbox = $bill_table->Checkbutton(-variable=>\$checkboxvalue[$t]); $bill_table->put($x,0, $checkbox);

Thanks again for all ya'll help


In reply to Re: Array of TK::Checkbuttons not acting appropriately by mikasue
in thread Array of TK::Checkbuttons not acting appropriately by mikasue

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.