Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Not able to display a image on a canvas in perl/tk

by GuptaNikhil (Initiate)
on Jul 25, 2013 at 05:32 UTC ( [id://1046259]=perlquestion: print w/replies, xml ) Need Help??

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');

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1046259]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-26 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found