I am building a GUI application using Python and Tkinter. I want to control the behavior of the program when the user closes it.
I've installed a new WM_DELETE_WINDOW
protocol using:
root = Tk()
root.protocol("WM_DELETE_WINDOW", lambda: closes_gracefully())
This indeed is working when the user clicks the X
button on the titlebar, but it is NOT working when the user presses ALT+F4.
I tried binding the key sequence: root.bind("<Alt-F4>", lambda: closes_gracefully())
but it did not work.
How can I capture the ALT+F4 event?