On 02/07/2007 02:20 PM, Herman Gerritsen wrote:
Hi there,

I have a seemingly simple problem.
I want a picture (format doesn't really matter to me, but I tried jpeg and
xpm) on a Tk::Canvas.

I have been reading Mastering perl/TK (oreilly) but somehow the explanations
in that book dont get to my brain...
Perldoc didnt get me there either..

Can anyone show me a simple script that displays a picture (preferably jpeg)
on a Tk::Canvas in a window?
I couldn't find an example I understood..

Thanks already.
Herman Gerritsen


#!/usr/bin/perl
use strict;
use Tk;

my $main = MainWindow->new;
my $label = $main->Label(-text => 'My Canvas.')->pack;
my $canvas = $main->Canvas()->pack;
my $qbtn = $main->Button(-text => 'Quit',
    -default => 'active',
    -command => [$main , 'destroy'])->pack->focus;

my $image = $main->Photo(-file => 'wallpaper_thumb.pnm');
$canvas->createImage(10,10, -image => $image, -anchor => 'nw');

MainLoop;


__HTH__



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to