Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: Syntax error using Tk

by eoin (Monk)
on Feb 16, 2004 at 18:53 UTC ( [id://329406]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Syntax error using Tk
in thread Syntax error using Tk

I've taken your advice and looked into Grid and believe it to be a better choice altogether. I've done a bit of reading and came up with this code but it goes into a continuous loop???
my $row = 0; my $column = 0; for (my $i = 9; $i >= 0; $i--) { $button{$i} = $mw->Button(-text => "$i", -width => '3', -height => '1', -command => &numpress($i)) ->grid(-row => $row, -column => $column); $column++; if($column > 2){$column = 0; $row++;} } MainLoop;
Any Ideas???

Cheers, Eoin...

Replies are listed 'Best First'.
Re: Re: Re: Re: Syntax error using Tk
by graff (Chancellor) on Feb 17, 2004 at 01:30 UTC
    Now the problem is here:
    -command => &numpress($i))
    The thing being assigned to the "-command" attribute needs to be an anonymous subroutine, a reference to a named subroutine, or else a reference to an array whose elements are: named_subroutine_ref, arg1(, arg2 ...) -- in other words, either of the following would be the right way to do what you want:
    -command => sub { numpress( $i ) } # or -command => [ \&numpress, $i ]
    The way you had it written, your subroutine is actually being called when the Button is being created, and Perl/Tk is trying to use the return value of the sub as the value for "-command" -- not good.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://329406]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found