use strict; use Tk; my @cbValues; my $mw = MainWindow->new; $mw->Button( -text => "Print Selected", -command => \&printSelected )->pack; my $rows = $mw->Frame->pack; ## $rows will serve as a gridded container for each ## of the checkbutton rows. This should be roughly ## similar to using Tk::Table, but less hassle ## for a quick & dirty example. for my $row (0 .. 9) { $rows->Label(-text => $row)->grid( $rows->Checkbutton( -command => [\&select, $row], -variable => \$cbValues[$row])); } MainLoop; sub select { my $i = shift; if ($cbValues[$i]) { print "Selected $i\n"; } else { print "Deselected: $i\n"; } } sub printSelected { my $row = 0; print "\nSelected:\n"; foreach my $val (@cbValues) { print "$row selected\n" if $val; $row++; } }