I m trying to keep a Toplevel window from being closed in OSX by intercepting window manager WM_DELETE_WINDOW event.
#!/usr/bin/env python
from Tkinter import *
def speak():
print "woof"
root = Tk()
root.title("root")
win = Toplevel()
win.title("win")
win.protocol( WM_DELETE_WINDOW , speak)
root.mainloop()
When I run this I get two pop up windows titled "root" and "win". If I click on the red "x" close button on "win" to close the window, prints "woof" and then closes. However, if I run this same code on windows "win" stays open and keeps printing "woof" every time I click the red "x" close button.
How can I keep the Toplevel window from closing on OSX when I click the red "x" close button?