in reply to
Re: Checkbutton in a loop
in thread Checkbutton in a loop
There is a third option, don't pass it any arguments
use Tk;
$mw = tkinit;
for(1..4){
$mw->Checkbutton(
-text => qq/check it $_/,
-command => \&f,
) ->pack;
}
MainLoop;
sub f {
my $b = $Tk::event->W;
warn join q/ /, $b->{Value}, $b->cget(q/-text/);
}
__END__
1 check it 3 at - line 14.
0 check it 3 at - line 14.
1 check it 3 at - line 14.
0 check it 3 at - line 14.
1 check it 3 at - line 14.
0 check it 3 at - line 14.
1 check it 3 at - line 14.
0 check it 3 at - line 14.