Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

how can I coerce Tk to cluck

by stefp (Vicar)
on May 13, 2002 at 19:40 UTC ( [id://166259]=perlquestion: print w/replies, xml ) Need Help??

stefp has asked for the wisdom of the Perl Monks concerning the following question:

How can I force Tk to print the stack of calls that led to an error? Below is a typical error obtained from Tk. The problem is that it does not tell me where I messed up.
No -label at /usr/lib/perl5/site_perl/5.6.1/i386-linux/Tk/Widget.pm li +ne 247

-- stefp -- check out TeXmacs wiki

Replies are listed 'Best First'.
Re: how can I coerce Tk to cluck
by {NULE} (Hermit) on May 13, 2002 at 20:25 UTC
    Hi,

    This is a good question. In this case the error is telling you that some widget requires a '-label' parameter and did not get it. (The prime example of this is the command method of a Menubutton widget, which if left without a label will produce this exact error.)

    Normally use Tk::ErrorDialog will produce a stack, with useful information, but neither that nor a custom Tk::Error sub will produce useful information in the example that I gave.

    sub Tk::Error { my ($widget, $error, @locations) = @_; print "Widget:\n\t$widget\n"; print "Error:\n\t$error\n"; print "Locations:\n"; map { print "\t$_\n" } @locations; }
    If you or anyone else comes upon a way to trap this kind of (rare) error that occurs outside of Tk's built-in error mechanism, I'd like to see it. In my experience this kind of thing is how pTk earns its undeserved bad reputation.

    Update: belg4mit snuck in a response a bit before me {g}, but I wanted to say that I have version 3.078 of Widget.pm as well and it does indeed produce this exact error at that line number if perform the action I describe above with the command method of a Menubutton widget. That is why this error appears to happen outside of Tk's Error handling mechanism.

    Good luck,
    {NULE}
    --
    http://www.nule.org

Re: how can I coerce Tk to cluck
by belg4mit (Prior) on May 13, 2002 at 20:16 UTC
    %SIG, signals. Tk also appears to have an AutoLoaded Error subroutine used for outputting other errors, you could override it (without strict).

    My Widget.pm (v3.078) here has no such warning in the code, and does in fact use Carp.

    --
    perl -pew "s/\b;([mnst])/'$1/g"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-19 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found