use Tk; use TK::JPEG; use Tk::Photo; use strict; use warnings; sub mk_thumbnail { my $win = shift; my $img = shift; my $photo = $win->Photo( -file => $img ); my $thumb = $win->Photo; my $w = $photo->width; my $h = $photo->height; $w = ( $w /60 ); $h = ( $h /60 ); $thumb->copy( $photo, -subsample => ( $w, $h ) ); $photo->delete; return $thumb; } my $mw = MainWindow->new; my %images; my ($row, $col) = ( 0,0 ); foreach my $img ( <*.jpg>, <*.bmp> ) { my $thumb = mk_thumbnail ( $mw, $img ); $images{$img}=undef; my $frame = $mw->Labelframe( -text => $img)->grid( -row => $row, -column => $col); my $lb1 = $frame->Label ( -image => $thumb)->pack; my $chk = $frame->Checkbutton ( -variable => \$images{$img} )->pack; $col++; if ($col == 4) { $col = 0; $row++; } } MainLoop; foreach my $k ( keys %images ){ print "$k:"; if ($images{$k} ) { print " selected.\n"; }else{ print " not selected.\n"; } }