Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Re: Re: Re: Re: Syntax error using Tk

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


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

Ok I'm nearly there. Still a few problems.
For some unseen reason I'm getting this error message, now I wasn't getting it earlier before I introduced the function buttons i.e + - \ * etc...
First of all I created another For loop, and another frame to house the function buttons. Esentially it was identical to the first for loop which created the buttons perfectly. But when I tried this loop I got the error message
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.
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 52.
I just don't understand it??
Heres the rest of it.
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;

Cheers, Eoin...

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Syntax error using Tk
by JamesNC (Chaplain) on Feb 18, 2004 at 16:03 UTC
    I don't know where line 52 is? The best advice I can give you is to learn to build a little/test alot, add a little more, test some more that way when something breaks, you will know most likely where it broke right away. If something doesn't behave as you understand it, read the docs, insert print debug statements and use the debugger. I don't mind helping folks that have gone that far, none of us do. Buy that "Mastering Perl/Tk" book.. it is really an indespensible item.
    JamesNC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-24 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found