#!/win2k/Perl/bin/perl use warnings; use strict; use Tk; our $CurrentImage = -1; our @Images = qw( D:/Wallpapers/tmp/wide.gif D:/Wallpapers/tmp/deepsea.gif D:/Wallpapers/tmp/flea.gif D:/Wallpapers/tmp/forest.gif ); our $MainWin = Tk::MainWindow->new(); our $ImgLabel = $MainWin->Label()->pack; $MainWin->overrideredirect(1); # Remove border and title bar from window $MainWin->bind('', [$MainWin, 'destroy']); $MainWin->bind('', \&prev_image); $MainWin->bind('', \&next_image); load_images(); next_image(); center($MainWin); MainLoop; sub next_image { $CurrentImage = ++$CurrentImage % @Images; $ImgLabel->configure(-image => $Images[$CurrentImage]); } sub prev_image { $CurrentImage = $#Images if(--$CurrentImage < 0); $ImgLabel->configure(-image => $Images[$CurrentImage]); } sub load_images { for my $image (@Images) { # Replace image filename w/ loaded image $image = $MainWin->Photo( -file => $image, -format => 'gif', ); } } sub center { my $win = shift; $win->withdraw; # Hide the window while we move it about $win->update; # Make sure width and height are current # Center window $win->geometry( '+' . int( ($win->screenwidth - $win->width) / 2 ) . '+' . int( ($win->screenheight - $win->height) / 2 ) ); $win->deiconify; # Show the window again }