use strict; use Tk; use Tk::WorldCanvas; my $can_height = 50; my $can_spacing = $can_height + 2; my $can_label_padx = 2; my $can_width = 50; my $can_total = 5; my @canvasList = (); my $mainwin = MainWindow->new(); my $thumbholder = $mainwin->Scrolled('Canvas', -scrollbars => "e", -scrollregion => [0, 0, 0, $can_total*$can_spacing], -height => 2*$can_spacing, -width => 3*$can_width, -yscrollincrement=> $can_height, )->pack(-side => 'top'); for (my $i = 0; $i < $can_total; $i++) { makeThumbnail($i); } # Now let the WorldCanvas objects do a smart rescale. $mainwin->update(); foreach my $can (@canvasList) { $can->viewAll; } MainLoop; sub makeThumbnail { my $i = shift; my $thumbcan = $thumbholder->WorldCanvas(-height => $can_height, -width => $can_width); $thumbholder->createWindow(0, $can_spacing*$i, -anchor => "nw", -window => $thumbcan); $thumbholder->createText($can_width + $can_label_padx, $can_spacing*$i, -anchor => "nw", -text => "Image " . $i); # Fake triangle object for illustration purposes. my $color = 'black'; my $width = 1; my @path = (10,50,40,-20,66,80,10,50); $thumbcan->createLine(@path, -fill => $color, -width => $width); push @canvasList,$thumbcan; }