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