For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > June 2004 > HELP!!!









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 HELP!!!
Tony Martone

2004-06-25, 7:10 pm

I am trying to display two separate images, one for each iteration of a
"for" loop. The second image is displayed twice. I think I may be packing
the widget at the wrong time. Below is the code. Any suggestions?

$Frames[0] = "file1.gif";
$Frames[1] = "file2.gif";

for($i=0; $i<2; $i++) {
#Create chapter frame within table and label it
$ChapterFrame = $table->Frame(-relief=>'groove', -borderwidth=>2);
$ChapterFrame->Label(-text=>"Image $i");
#$table->put($i,0,$ChapterFrame );
#Create a frame within child and load an image into that frame area
$frame = $table->Frame(-relief=>'groove', -borderwidth=>2);
$img = $frame->Photo('imggif', -file=> $Frames[$i]);
$imglabel = $frame->Label(-image => $img);
$imglabel->pack();
$ChapterFrame ->pack();
$table->put($i,0,$ChapterFrame );

} # end of for loop


Marc Dashevsky

2004-06-25, 7:10 pm

In article <cbf62l$a78$1@mozo.cc.purdue.edu>, amartone@ecn.purdue.edu says...
> I am trying to display two separate images, one for each iteration of a
> "for" loop. The second image is displayed twice. I think I may be packing
> the widget at the wrong time. Below is the code. Any suggestions?


You are naming the second image the same as the first, imggif,
so the first is over written. Don't worry about when you
pack the frames and labels. Here is a working for loop:

my @groove = (-relief => 'groove', -borderwidth => 2);
for (my $i = 0; $i < 2; $i++) {
my $ChapterFrame = $table->Frame(@groove)->pack;
$ChapterFrame->Label(-text => "Image $i")->pack;
my $frame = $table->Frame(@groove)->pack;
my $img = $frame->Photo(-file => $Frames[$i]);
$frame->Label(-image => $img)->pack;
}

> $Frames[0] = "file1.gif";
> $Frames[1] = "file2.gif";
>
> for($i=0; $i<2; $i++) {
> #Create chapter frame within table and label it
> $ChapterFrame = $table->Frame(-relief=>'groove', -borderwidth=>2);
> $ChapterFrame->Label(-text=>"Image $i");
> #$table->put($i,0,$ChapterFrame );
> #Create a frame within child and load an image into that frame area
> $frame = $table->Frame(-relief=>'groove', -borderwidth=>2);
> $img = $frame->Photo('imggif', -file=> $Frames[$i]);
> $imglabel = $frame->Label(-image => $img);
> $imglabel->pack();
> $ChapterFrame ->pack();
> $table->put($i,0,$ChapterFrame );
>
> } # end of for loop


--
Go to http://MarcDashevsky.com to send me e-mail.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com