After that happened I tried to figure out what was wrong but I couldn't spot it, so Idecided to just use the first loop for all the buttons. So I introduced the extra buttons in the array and added in the part to make the + and = buttons bigger. I tested it and got the same error: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 66.
I just don't understand it??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.
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 } ); for my $i ( qw/ 7 8 9 * n* 4 5 6 - \ 1 2 3 + = 0 . C / ) { if($i eq '+' || $i eq '=') { $h = 2; } $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;
In reply to Re: Re: Re: Re: Re: Re: Syntax error using Tk
by eoin
in thread Syntax error using Tk
by eoin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |