#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::Photo; use Tk::JPEG; #this one stores the photo objects in a hash my (%img_obj, @keys, $image); my $count = 0; my $main = new MainWindow; &load_images; my $imglab = $main->Label( -height => 600, -width => 600, -image => $image )->pack; my $label = $main->Label()->pack; my $label2 = $main->Label()->pack; my $button1 = $main->Button( -text => 'faster', -command => \&faster )->pack; my $button2 = $main->Button( -text => 'slower', -command => \&slower)->pack; my $rpt = 400; my $min = 60; # increase this if it starts to freeze at fastest setting my $max = 5000; # increase if you want more time per image my $incdec = 20; # default 50ms increase/decrease my $time_this = $main->repeat( $rpt, \&show_pic ); $label2->configure( -text => $rpt ); MainLoop; sub slower { return if $rpt > $max; $rpt += $incdec; $time_this->time($rpt); $label2->configure( -text => $rpt ); } sub faster { return if $rpt < $min; $rpt -= $incdec; $time_this->time($rpt); $label2->configure( -text => $rpt ); } sub show_pic { push (@keys,shift(@keys)); #circular list $image->blank; $imglab->configure(-image => $img_obj{ $keys[0] } ); $label->configure( -text => $keys[0] ); } sub load_images { my @files = ; foreach my $file (@files) { $img_obj{ $file } = $main->Photo( '-format' => 'jpeg', '-file' => $file); } @keys = keys %img_obj; $image = $img_obj{ $keys[0] }; } __END__