0

I tried win.overrideredirect(True) it didn't work...

My Code goes like this:

from tkinter import *

win = Tk()
win.resizable(0,0)
win.wm_protocol("WM_SAVE_YOURSELF", lambda: print("On exit"))
Label(win, text="Tk Window").pack()
win.mainloop()

Specs: Python 3.9.6 [Latest], Pip 21.1.3, OS: Windows 10 Home

I want to make the minimize button to be disabled... Please help

  • _"it didn't work..."_ - that's very vague. Why do you think it didn't work? What happened when you did it? – Bryan Oakley Jul 10 '21 at 16:34
  • `WM_SAVE_YOURSELF` is deprecated. *WM_DELETE_WINDOW* should work. – Thingamabobs Jul 10 '21 at 16:50
  • @Atlas435 Can you please tell me your source? I found [this](https://stackoverflow.com/a/50630990/11106801) which links to [this](https://wiki.tcl-lang.org/page/wm+protocol) but it doesn't say that it's deprecated. I am thinking of using it in one of my projects so I want to know if it's deprecated. – TheLizzard Jul 10 '21 at 18:20
  • @Atlas435 I have tried both and *WM_DELETE_WINDOW* is to prevent the window from closing... But I want to disable the functionality of minimize button... I have searched all over the internet but could not find anything relevant... – Himangshu De Jul 10 '21 at 19:25

3 Answers3

0

Found this here:

import Tkinter as tk

root= tk.Tk()

root.title("wm min/max")

# this removes the maximize button
root.resizable(0,0)

# # if on MS Windows, this might do the trick,
# # but I wouldn't know:
# root.attributes(toolwindow=1)

# # for no window manager decorations at all:
# root.overrideredirect(1)
# # useful for something like a splash screen

root.mainloop()
N1CK145
  • 59
  • 1
  • 11
  • "root.attributes(toolwindow=1)" giving an error TypeError: wm_attributes() got an unexpected argument 'toolwindow' – Himangshu De Jul 10 '21 at 15:29
  • @HimangshuDe try only this line `root.resizable(0,0)` – N1CK145 Jul 10 '21 at 15:30
  • I also did that but that didn't work... I want to completely disable functioning of minimize button in the window manager decoration – Himangshu De Jul 10 '21 at 16:31
  • @HimangshuDe Try `root.attributes("-toolwindow", True)`. It worked for me. – TheLizzard Jul 10 '21 at 18:12
  • @TheLizzard Voila, that's working, Thanks... You may post your answer in the answer section! – Himangshu De Jul 10 '21 at 19:34
  • I need a window that is resizable, maximizable, and closable, but not minimizable (to cut down on confusion when this window must be closed and is blocking other things), so I tried the 'toolwindow' idea, but then no icon is placed in the taskbar and I found many ways to lose the window on my screen and not be able to find it again (i.e. it didn't solve the problem of reducing confusion). In the end I used a binding that catches the '' call, but the window still minimizes and I deiconify it if it becomes unviewable (minimized). It's very kludgy and I'm searching for something better. – Pete P Dec 09 '21 at 23:23
0

try resizeable function like this :

win= Tk()

win.geometry("750x250")

win.resizable(False, False)
0

The thing @N1CK145 posted didn't work for me but I am guessing that he/she tried to do this:

import Tkinter as tk

root = tk.Tk()
root.attributes("-toolwindow", True)
root.mainloop()

If you want to know more attribute options look here

TheLizzard
  • 7,248
  • 2
  • 11
  • 31