2

Looking for advice on how to remove or disable a resizable window's maximize button under Windows. I'm using Python 2.7 for Windows.

Background: I have a resizable window with min and max sizes set via the window's minsize() and maxsize() methods. When a user clicks the maximize button, the window moves to the upper left of the display. This is very confusing to my users so I would like to prevent that behavior.

My research shows several ways to disable a maximize button - but none of these techniques seem to apply to resizable windows?

  1. Prevent a window from resizing via the resizable( False, False ) method.

  2. Remove all the window's controls (and border) via the overrideredirect( True ) method.

  3. Use the mysterious transient(1) method (this raises an exception under Windows).

  4. Bind the window's event and try to block the maximize (update: Tkinter has already maximized the window by the time our handler detects the maximize event. Returning "break" or using geometry(size|position) to size and re-position a window are both ignored)

  5. I've posted a question on the Python Win32 API mailing list to see if we can use a Windows API call to disable a window's maximize button via the hWnd handle that I believe(?) Tkinter exposes.

Is there a way I can trap the maximize event (BEFORE Tkinter performs it)?

Malcolm

4

1 回答 1

4

一种可能性是将窗口设置为工具窗口,但这也有副作用;该窗口将不再出现在任务栏中,并且将有一个细的标题栏。它仍然可以在边缘调整大小。

root.attributes("-toolwindow", 1)

有关根属性的更多信息,请参阅本指南

于 2011-03-24T23:41:58.203 回答