How to catch the maximize signal in Tk?

大城市里の小女人 提交于 2020-03-22 07:54:13

问题


You can bind a command with the X button of the window by this:

wm protocol $windowPath WM_DELETE_WINDOW $command

How can I do the same for the maximize button of the window?


回答1:


There's no standard protocol for it, either among the X11 ICCCM set or the FreeDesktop set. As such, wm protocol cannot possibly be used for it. However, you can use the <Configure> event to track all size changes for a window. Note that if you set it on a toplevel, you will also get notifications for all widgets inside that window, so you should check to see if the event was really about the toplevel before acting on it, perhaps like this:

bind $toplvl <Configure> {
    if {"%W" eq [winfo toplevel "%W"]} {
        ActOnResize %W %w %h [wm attributes %W -zoomed]
    }
}

You might also want to check the -fullscreen attribute.



来源:https://stackoverflow.com/questions/4643887/how-to-catch-the-maximize-signal-in-tk

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