tkinter mac,最小化屏幕 [英] tkinter mac, minimize screen
问题描述
我正在Mac的python中使用tkinter.
I'm using tkinter in python for mac.
简而言之,我想覆盖最小化"按钮的功能.
Simply put, I want to override the "minimize" button's functionality.
我已经以这种方式覆盖了"X"按钮的功能:
I'm already overriding the "X" button functionality in this fashion:
root = Tk()
root.protocol('WM_DELETE_WINDOW', doClose)
我尝试过的事情:
我查看了WM状态,没有WM_ICONIFY_WINDOW
或WM_MINIMIZE_WINDOW
.我也尝试使用WM_SAVE_YOURSELF
,但无法捕获任何中断.
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.
当人们点击最小化"而不是默认设置时,使tkinter达到我想要的最知名的方法是什么?
what's the best known way of making tkinter do what I want when people hit "minimze" rather than the default settings?
谢谢!
推荐答案
没有用于最小化的标准WM_PROTOCOL
消息.看来,最好的解决方案-捕获<Unmap>
事件:
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()