简体   繁体   中英

Disable Window buttons Tkinter

Im creating a tkinter program and was wondering if you could disable the buttons on the top bar of the window. So far I have tried

menu.protocol("WM_DELETE_WINDOW", button_pressed)
menu.protocol("WM_MINIMIZE_WINDOW", button_pressed)

def button_pressed():
    pass

and

menu.overrideredirect(1)

Problem 1:

In the first one, the minimize button still makes the window dissapear, as im not sure the WM_MINIMIZE_WINDOW is correct. However, the WM_DELETE_WINDOW works.

Problem 2:

using menu.overrideredirect(1) means that I cannot make the window fullscreen and that is one of the main features of my program.

Probably the first one would be better so what is the correct way to use it?

If either of these methods are not possible, let me know a possible way to disable the buttons!

Try this @Legacy Coding:

root = tk.Tk()
root.overrideredirect(True)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
root.resizable(width=FALSE, height=FALSE)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM