Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl reference, trouble with TKs label/image

Status
Not open for further replies.

longstocks

Programmer
Joined
Dec 16, 2006
Messages
1
Location
NO
To avoid typing the same many lines 9 times, (and because i didnt figure out why one of the images were missing) i made a sub and used references to blablabla you get the deal when you look at the code :) take a look at the code. The problem is the image doesn't show.
When not using refs and a sub the result of everything looked like this:
Btw it's just a christmas gift for my younger sister.


Thanks for the help, it's greatly appreciated!

Code:


#!/usr/bin/perl

use Tk;
use Tk::Photo;
use Tk::Button;


my $vindu = MainWindow->new(-name => 'vindu', -title=>'Overnoobfriendly ZSNES interface');

sub rendergame {

$spill = shift @_;
$tekst = shift @_;
$file = $spill.".gif";
$l_ref = shift @_;
$fl_ref = shift @_;
$b_ref = shift @_;
$row = shift @_;
$col = shift @_;

$$l_ref = $vindu->Label( );
$$f1_ref = $vindu->Photo( -file => $file);
$$l_ref->configure( -image => $$fl_ref );
$$b_ref = $vindu->Button(-text => "Spill $tekst!", -command => sub {system("ZSNESW.EXE $spill.smc")});

$$l_ref->grid(-row=>$row,-column=>$col);
$$b_ref->grid(-row=>++$row,-column=>++$col,-sticky=>'ew');

}
rendergame("allstars","Super Mario Allstars",\$l_allstars,\$fl_allstars,\$b_allstars,1,1);
Tk::MainLoop;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top