Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Tk::Error: ("after" script)

by wulvrine (Friar)
on Sep 27, 2007 at 14:06 UTC ( [id://641356]=perlquestion: print w/replies, xml ) Need Help??

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

Hello fellow monks

I am writing a Perl::Tk program which is throwing an error Tk::Error: ("after" script) when it is exiting. During the main loop of the program, there is a DialogBox called. This box has an 'exit' button.

my $dlg=$mw->DialogBox(-title=>'Winner', -buttons=>["Again","Exit"]); my $b=$dlg->Show(); if ($b eq "Again") { ... } else { $mw->destroy(); exit; }
When the "Exit" button is pressed, $mw->destroy(); is called. The program then prints
Tk::Error:
("after" script)

What does this error really mean, and how do I get rid of this error?
Thanks!

s&&VALKYRIE &&& print $_^q|!4 =+;' *|

Replies are listed 'Best First'.
Re: Tk::Error: ("after" script)
by zentara (Archbishop) on Sep 27, 2007 at 16:30 UTC
    Hi, I can't reproduce your error, it seems to run Ok here, but it probably depends on system load and timing, (and maybe Tk version). I did see similar problems in the past, and from my experience, your problem is in "$mw->destroy". Why? Well your DialogBox is a child of $mw, and if you destroy $mw, you destroy the MainLoop (event loop) and leave the $dlg hanging in mid-air. It is better to use Tk::exit ( or even plain exit), to exit a Tk program. Tk::exit will clean up after itself. General rule: Don't use $mw->destroy unless you are trying to continue the script in a non-Tk mode.

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum
Re: Tk::Error: ("after" script)
by liverpole (Monsignor) on Sep 27, 2007 at 16:00 UTC
    Hi wulvrine,

    As I mentioned to you, I've seen this exact same error from one or two perl/Tk programs of my own, but I've never figured out exactly what the cause was.  My recollection is that it was intermittent; sometimes it happened and sometimes not.

    I'll be very curious to see whether others have had this happen, and especially if someone knows the answer to this.


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
Re: Tk::Error: ("after" script)
by wulvrine (Friar) on Sep 28, 2007 at 18:38 UTC
    zentara
    Thanks for the ideas! I think it has to do with having the dialog box up at all. If I display the dialog box and then use Tk::exit or just plain exit the program doesnt stop, the Tk window closes, but the 'repeat' loop keeps running and I still get the errors. However, if I do not display a dialog box and just plain exit, it works fine.
    Is there something special that needs to be done once a dialog box is shown to properly exit?

    s&&VALKYRIE &&& print $_^q|!4 =+;' *|

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-24 22:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found