[Tkinter-discuss] Removing/disabling a resizable window's maximize button under Windows

Michael Lange klappnase at web.de
Thu Dec 2 11:21:19 CET 2010


Thus spoketh python at bdurham.com 
unto us on Wed, 01 Dec 2010 23:31:00 -0500:

> Is there a way I can trap the maximize event (what event to bind
> to?) and return "break" to prevent the maximize from happening
> (or better yet, substitute my own behavior instead)?

The only thing I can think of is to catch the <Configure> event and try
to determine the current state of the window, like:

def on_configure(event):
    if event.widget.wm_state() == 'zoomed':
        ...update the window geometry as desired...

root.bind('<Configure>`, on_configure)

The "zoomed" state seems to be valid only for windows and OSX, not X11,
so I cannot test this here on my linux box.
Alternatively, as a last resort, you might try to remove the title bar
with overrideredirect and create your own title bar; the maximize button
then should toggle between wm_state('zoomed') and wm_state('normal') on
the window.

I hope this helps


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

Either one of us, by himself, is expendable.  Both of us are not.
		-- Kirk, "The Devil in the Dark", stardate 3196.1

More information about the Tkinter-discuss mailing list