问题
I'm using tkinter in python for mac.
Simply put, I want to override the "minimize" button's functionality.
I'm already overriding the "X" button functionality in this fashion:
root = Tk() root.protocol('WM_DELETE_WINDOW', doClose)
What I tried:
I looked into the WM states and there is no WM_ICONIFY_WINDOW
or WM_MINIMIZE_WINDOW
. I also tried working with WM_SAVE_YOURSELF
but couldn't catch any interrupt.
what's the best known way of making tkinter do what I want when people hit "minimze" rather than the default settings?
Thanks!
回答1:
There is no standard WM_PROTOCOL
message for minimization. It seems, the best solution - catching <Unmap>
events:
from Tkinter import *
root = Tk()
def callback(event):
print event
frame = Frame(root, width=100, height=100)
frame.bind("<Unmap>", callback)
frame.pack()
root.mainloop()
Related links: 1, 2, 3
来源:https://stackoverflow.com/questions/26156559/tkinter-mac-minimize-screen