tkinter mac, minimize screen

独自空忆成欢 提交于 2019-12-24 03:46:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!