We need to see less code. Focus down on the two lines that are causing your trouble and just enough other lines so that we can reproduce it. Your sample code has far too many unknown entities. Try adding use strict; use warnings; and if it doesn't compile clean (appart from your error) then clean it up.
Are any of the ->put lines relevant to the problem?
I'd guess you are after something like the following (but I can't tell from your code):
use strict; use warnings; use Tk; my @unpaidbills = (['Fred', 1.27], ['Joe', 3.46], ['Francis', 2.22], [ +'Joanne', 5.23]); my @checkboxes; my $main = new MainWindow; foreach my $bill (@unpaidbills) { my $state = 0; # Note we get a new $state each time through my $button = $main->Checkbutton ( -text => "$bill->[0]: $bill->[1]", -variable => \$state ); $button->pack (); $checkboxes[@checkboxes] = [$button, $bill, \$state]; } $main->Button(-text=>'Submit', -command=> [\&doSubmit, \@checkboxes])- +>pack (); MainLoop (); sub doSubmit { my ($checkboxes) = @_; for my $entry (@$checkboxes) { my ($button, $bill, $state) = @$entry; if ($$state) { print "$bill->[0] paid \$$bill->[1]\n"; } else { print "\$$bill->[1] not paid for $bill->[0]\n"; } } }
In reply to Re: Array of TK::Checkbuttons not acting appropriately
by GrandFather
in thread Array of TK::Checkbuttons not acting appropriately
by mikasue
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |