OK, let's look at the three “interesting” lines, one by one.
bind $toplvl <Configure> {
This attaches a binding to the <Configure>
event to the binding tag in $toplvl
, which I presume is the name of a toplevel
widget. The <Configure>
event is delivered when the size or position of a widget is changed (plus a few technical things that Tk doesn't really use).
if {"%W" eq [winfo toplevel "%W"]} {
First off, %W
is replaced with the name of the widget that the event was dispatched to. This line makes what follows conditional on the event being delivered to an actual toplevel widget, which is useful because toplevels also receive events sent to all their children (great for binding hotkeys, not so great for other events).
ActOnResize %W %w %h [wm attributes %W -zoomed]
This calls the command ActOnResize
, passing in four arguments: the (toplevel) widget name, the new width, the new height, and whether the toplevel is zoomed or not (which has to be retrieved with that call to wm attributes
).
High Level Summary
Call ActOnResize
whenever the toplevel changes size or is moved relative to its parent window (which is logically the desktop root), passing in its new size and a boolean that indicates if it's maximized.