You will want to get a "Photo" handle on the file as in the following example where 'imggif' is the Photo handle for a gif file that is distributed with Tk-b#:
#!/usr/bin/perl -w use strict; use Tk; my $main = new MainWindow; $main ->Label(-text => 'Main')->pack; $main -> Photo('imggif', -file => "$Tk::tk_library/demos/images/earth.gif"); my $l = $main->Label('-image' => 'imggif')->pack; $main->Button(-text => 'close', -command => sub{destroy $main} )->pack(-side => 'left'); $main->Button(-text => 'exit', -command => [sub{exit}] )->pack(-side => 'right'); MainLoop;(Canvas widgets are another story however see question a later question within this FAQ).
Previous | Return to table of contents | Next