I'm using Tcl/Tk to build a GUI, for Linux environment and I saw that it's possible to "catch" a press on the 'x' button of the window (The button on the top right corner that closes the program).
How can I catch those events?
To take control of requests to delete a window, configure a suitable protocol handler:
wm protocol . WM_DELETE_WINDOW {
if {[tk_messageBox -message "Quit?" -type yesno] eq "yes"} {
exit
}
}
The default behavior (i.e., if the protocol handler is the empty string) is to just destroy
the toplevel to which the request was made.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With