#!/usr/bin/perl -w use Tk; use strict; use warnings; use Tk::JPEG; use Tk::PNG; my $mw = MainWindow->new; # I have a photo that is 500w x 430h # so make the $mw a bit bigger # This step can be automated to accept any size image # but I hardcode the numbers for this simple example $mw->geometry("510x440"); # gave $mw extra 10 pixels h and w to hold canvas # you need to be careful about specifying all sizes, and # borderwidths, so that no scroll occurs # you also probably need to set the scrollregion to the # exact photo size. #you also will have problems if someone resizes the mainwindow # you may need PDF, or SVG images, which Tk dosn't support yet # So you may want to make your window non-resizable # $mw->resizable(0,0); my $canvas1 = $mw->Canvas(-bg=>'lightgreen', -width=> 500, -height=>430, -scrollregion=>[0,0,500,430], )->pack(-expand=>0,-fill=>'none'); my $bg_img = $mw -> Photo(-file=>'1Zen16.jpg'); $canvas1->createImage(0,0, -image => $bg_img, -anchor => 'nw', -tags => ['img'], ); MainLoop;