how to disable maximize button?

David LeBlanc whisper at oz.net
Sun Jul 7 14:53:56 EDT 2002


IIRC, Tk itself has the capability to trap the quit button on the window,
and that _should_ be the same mechanism to catch a click on any of the
window "system" buttons. (This pertains to MS-Windows.)

In general terms, for MS-Windows, you have to set a handler to capture the
WM_SYSCOMMAND message and the wparam arg will have the type of action
(minimize, maximize, quit etc.) that's being passed.

Tk has a means to set a handler for what it calls protocol events, but after
reading the Tk code itself, it only seems to work with WM_DELETE_WINDOW -
which curiously, isn't a standard MS-Windows event name! I tried setting an
event handler for WM_SYSCOMMAND in Tkinter, but it never fired (also, there
seems to be no way to get args passed with the event).

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Cameron Laird
> Sent: Sunday, July 07, 2002 5:32
> To: python-list at python.org
> Subject: Re: how to disable maximize button?
>
>
> In article <ornV8.47900$vm5.1715632 at news2.tin.it>,
> Alex Martelli  <aleax at aleax.it> wrote:
> >jubafre at zipmail.com.br wrote:
> >
> >> how i can disable de maximise button in tkinter, i don´t want the user
> >> modific the size of the window, i want a real size of window,
> how can i do
> >> it???
> >
> >You can remove all decorations:
> >
> >import Tkinter
> >root = Tkinter.Tk()
> >root.overrideredirect(1)
> >
> >Apart from this, you may choose to fix the size:
> >
> >import Tkinter
> >root = Tkinter.Tk()
> >root.resizable(0,0)
> >
> >
> >I know of no way to affect the maximize button ONLY, without also
> >affecting other ways to resize the window, but then from your post's
> >text I don't see why you should ONLY want to affect said button.
> >
> >
> >Alex
> >
> >
>
> It is possible, though.  That is, I believe, without making
> the time to verify this myself, that there's an effective way
> to achieve this under crucial window managers.
>
> You're right, Alex, that overrideredirect achieves what makes
> sense in this area.  However, as I believe you know, many
> vertical applications Windows hosts are configured with maximize
> and remove-window buttons disabled, leaving only iconify.  Clients
> expect to see this, whatever we think of its (ir)rationality.  Al-
> though Tkinter proper doesn't provide a means to achieve this,
> there are win32 calls accessible through *that* module that
> make it happen.
>
> I've forgotten what they are.  If I were going to pursue this,
> I'd check with operating-system experts for the correct lower-
> level calls.
> --
>
> Cameron Laird <Cameron at Lairds.com>
> Business:  http://www.Phaseit.net
> Personal:  http://starbase.neosoft.com/~claird/home.html
> --
> http://mail.python.org/mailman/listinfo/python-list






More information about the Python-list mailing list