Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what the "on exit" binding?

Status
Not open for further replies.

redsss

Programmer
Mar 17, 2004
72
US
I'm learning perl/tk programming - what tk binding can I use to call a function that does cleanup before closing the app when clicking on the X in the upper right?

I guess this would be the equivalent of the VB unload method.
 
Is there not just a simple way to declare an "onExit" callback function, using the bind method on the mainWindow?
 
Nope. You can bind other windows with <destroy> and a command, but the program will exit before it executes the command on the toplevel "." window.

What I do sometimes, is I set the WM_DELETE_COMMAND to do nothing, then I'll have an "Exit" button or menu choice that calls cleanup routines.

 
Thanks for your help. I realize this is not a perl forum and I don't know TCL althought its not the only language that binds to Tk, but I think I figured out the way to do this in perl:
Code:
$mw->protocol('WM_DELETE_WINDOW' => sub { cleanup(); exit;} );
Look good?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top