简体   繁体   English

禁用 Window 按钮 Tkinter

[英]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.我正在创建一个 tkinter 程序,想知道是否可以禁用 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.在第一个中,最小化按钮仍然使 window 消失,因为我不确定WM_MINIMIZE_WINDOW是否正确。 However, the WM_DELETE_WINDOW works.但是, WM_DELETE_WINDOW有效。

Problem 2:问题2:

using menu.overrideredirect(1) means that I cannot make the window fullscreen and that is one of the main features of my program.使用menu.overrideredirect(1)意味着我不能使 window 全屏,这是我程序的主要功能之一。

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:试试这个@Legacy 编码:

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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