Hi, here is another way to put checkboxes with your text. There is a small mismatch in the scrolling, but you should be able to fix it.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
my @List = (0..50);
my @cbvalue;
my @cbs;
my $mw = tkinit;
$mw->geometry("400x400+100+100");
$mw->fontCreate('big',
-weight=>'bold',
-size=> 14
);
my $button = $mw->Button(-text => 'show selected',
-command => \&show_selected,
-bg => 'yellow',
-font => 'big',
)->pack();
my $pane = $mw->Scrolled('Pane',-bg=> 'lightblue')
->pack( -expand => 1, -fill => 'y' );
my $canvas = $pane->Canvas(
-bg => 'white',
-width => 400,
-height => 800,
)->pack(-expand => 1, -fill => 'both');
foreach my $i ( 0 .. $#List ) {
$cbs[$i] = $canvas->Checkbutton(
-text => "Number $List[$i]",
-onvalue => 1,
-offvalue => 0,
-variable => \$cbvalue[$i],
-font => 'big',
-bg => 'lightseagreen',
)->pack();
$cbvalue[$i] = 0; #initialize selections to off
}
MainLoop;
sub show_selected {
my @selected;
foreach my $i ( 0 .. $#List ) {
if ($cbvalue[$i] == 1){push @selected, $i}
}
print "selected: @selected\n";
}