Home > Archive > PerlTk > February 2008 > packing a Tk::Photo widget
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
packing a Tk::Photo widget
|
|
| Abigail 2008-02-27, 7:07 pm |
|
I'm trying to make a simple application that displays an image.
However, 'pack' insists I give it an option, but I've no clue
what option it wants. Neither the Tk::Photo manual page, nor
"Mastering Perl/Tk" seem to provide a solution.
Sample program:
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
no warnings 'syntax';
use Tk;
use Tk::JPEG;
my $file = "00.jpg";
say "Tk version: $Tk::VERSION";
my $MW = MainWindow -> new;
my $photo = $MW -> Photo (-file => $file);
$photo -> pack;
MainLoop;
__END__
Output:
Tk version: 804.028
wrong # args: should be "pack option arg ?arg ...?" at /home/abigail/...
Any hints?
Abigail
--
:;$:=~s:
-:;another Perl Hacker
:;chop
$:;$:=~y
:;::d;print+Just.
$:;
| |
| Ch Lamprecht 2008-02-27, 7:07 pm |
| Abigail schrieb:
> I'm trying to make a simple application that displays an image.
> However, 'pack' insists I give it an option, but I've no clue
> what option it wants. Neither the Tk::Photo manual page, nor
> "Mastering Perl/Tk" seem to provide a solution.
>
> Sample program:
>
> #!/usr/bin/perl
>
> use 5.010;
>
> use strict;
> use warnings;
> no warnings 'syntax';
>
> use Tk;
> use Tk::JPEG;
>
> my $file = "00.jpg";
>
> say "Tk version: $Tk::VERSION";
>
> my $MW = MainWindow -> new;
> my $photo = $MW -> Photo (-file => $file);
>
> $photo -> pack;
>
> MainLoop;
>
>
> __END__
>
>
> Output:
>
> Tk version: 804.028
> wrong # args: should be "pack option arg ?arg ...?" at /home/abigail/...
>
>
>
> Any hints?
>
>
> Abigail
Hi,
a Tk::Photo isn't a Tk::Widget
You would use a Tk::Label and pass the Tk::Photo instance to its -image option.
(See Zentaras post of 2008-02-23)
HTH, Christoph
--
use Tk;use Tk::GraphItems;$c=tkinit->Canvas->pack;push@i,Tk::GraphItems->
TextBox(text=>$_,canvas=>$c,x=>$x+=70,y=>100)for(Just=>another=>Perl=>Hacker);
Tk::GraphItems->Connector(source=>$i[$_],target=>$i[$_+1])for(0..2);
$c->repeat(30,sub{$_->move(0,4*cos($d+=3.16))for(@i)});MainLoop
|
|
|
|
|