eoin has asked for the wisdom of the Perl Monks concerning the following question:
From what I understand from the error is that it is saying that $rows[$r] is undefined. Where as @rows is quite clearly defined, as is $r.Uncaught exception from user code: Can't call method "Button" on an undefined value at C:\Documents and S +ettings\Eoin\Desktop\calc.pl line 52.
Now i'm really confused!!for my $i ( qw/ 7 8 9 * n* 4 5 6 - \ 1 2 3 + = 0 . C / )
If anyone has any ideas on whats causing the problem, feel free to let me know. All and any help is greatly appriciated. :)my $mw = new MainWindow(-title => 'Calc'); $mw->geometry("300x300"); my $topframe = $mw->Frame(-height => '60', -width => '300')->pack(-sid +e => 'top', -expand => '0', -fill => 'x' +); my $btmframe = $mw->Frame(-height => '225', -width => '300',)->pack(-s +ide => 'left', -expand => '1', -fill => +'both'); push @rows, $btmframe->Frame()->pack( -expand => 1, -fill => 'both', - +side => 'top') for (0..3); my $display = $topframe->Entry(-justify => 'right', -state => 'disabled', -textvariable => \$calc) ->pack(-expand => '1', -fill => 'x', -pady => 30, -padx => 20, -side => 'right'); $mw->bind("<KeyRelease>" , sub { &keypress } ); my $r = 0; for my $i ( qw/ 7 8 9 * n* 4 5 6 - \ 1 2 3 + = 0 . C / ) { if($i eq '+' || $i eq '=') { $h = 2; } ########LINE 52 BELOW################ $button{$i} = $rows[$r]->Button(-text => "$i", -width => '3', -height => "$h", -command => sub { &btnpress($i) }) ->pack(-expand => 1, -fill => 'both', -padx => 2, -pady => 2, -side => 'left', -ipadx => 5, -ipady => 5); $w++; $h = 1; if($w > 2){$w = 0; $r++;} } MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undefined Button method??
by antirice (Priest) on Feb 18, 2004 at 17:30 UTC | |
by eoin (Monk) on Feb 19, 2004 at 09:15 UTC | |
|
Re: Undefined Button method??
by zentara (Cardinal) on Feb 18, 2004 at 17:39 UTC | |
by eoin (Monk) on Feb 19, 2004 at 17:23 UTC | |
|
Re: Undefined Button method??
by graff (Chancellor) on Feb 19, 2004 at 03:27 UTC |