GuptaNikhil has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to display an image on a canvas using perl/Tk but it is not being displayed. The code i have written is

#!/pkg/qct/software/perl/current/bin/perl -w use Tk; use Tk::JPEG; use Tk::Photo; my $mw = MainWindow->new; my $c = $mw->Canvas; my $image = $c->Photo(-file => '/usr2/nikhilg/final_proj/Floorplan.jpg +', -format=>"JPEG"); print $image; $c->createImage(100,100, -image => $image); MainLoop;

the $image that i am printing is displaying Tk::Photo=HASH(some hex number), but image is not displayed on the canvas. Any help will be highly appreciated. Thanks.

Replies are listed 'Best First'.
Re: Not able to display a image on a canvas in perl/tk
by Loops (Curate) on Jul 25, 2013 at 05:43 UTC
    You need to tell the geometry manager how to arrange widgets. So minimally something like this:
    $c->pack(-expand => 1, -fill => 'both');