问题
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