如何在不删除/禁用关闭按钮的情况下删除/禁用最小化按钮

发布于 2025-01-20 01:39:17 字数 601 浏览 5 评论 0原文

我正在使用Python中的TKINTER构建一个简单的登录系统,因为我需要一个不可避免的登录系统,并且可以通过'可重新设备(0,0)来完成,但它仅禁用最大化按钮。但是,我也将最小化的按钮也被禁用,所以请有人帮助我找到这些解决方案。

这是我的代码的示例,

from tkinter import *

root = Tk()
root.geometry("400x300")


def signIn():

    # Opening a new window for SignIn options
    signin = Toplevel()
    signin.grab_set()
    signin.focus_set()

    # I also tried this but it removes the whole title bar along with the close 'X' button
    # root.overrideredirect(True)

# SignIn button
button = Button(root, text="Sign In", command=signIn)
button.grid(row=1, column=0)

root.mainloop() 

I am building a simple login system using Tkinter in python, for that I need a non-resizable and it can be done by 'resizable(0,0) but it only disables the maximize button. But I what the minimize button to be disabled also, so please someone help me find the solution for these.

Here's the sample of my code,

from tkinter import *

root = Tk()
root.geometry("400x300")


def signIn():

    # Opening a new window for SignIn options
    signin = Toplevel()
    signin.grab_set()
    signin.focus_set()

    # I also tried this but it removes the whole title bar along with the close 'X' button
    # root.overrideredirect(True)

# SignIn button
button = Button(root, text="Sign In", command=signIn)
button.grid(row=1, column=0)

root.mainloop() 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

定格我的天空 2025-01-27 01:39:17
from tkinter import *

root = Tk()
root.geometry("400x300")
root.attributes('-toolwindow', True)

def signIn():

    # Opening a new window for SignIn options
    signin = Toplevel()
    signin.grab_set()
    signin.focus_set()

    # I also tried this but it removes the whole title bar along with the close 'X' button
    # root.overrideredirect(True)

# SignIn button
button = Button(root, text="Sign In", command=signIn)
button.grid(row=1, column=0)

root.mainloop()

from tkinter import *

root = Tk()
root.geometry("400x300")
root.attributes('-toolwindow', True)

def signIn():

    # Opening a new window for SignIn options
    signin = Toplevel()
    signin.grab_set()
    signin.focus_set()

    # I also tried this but it removes the whole title bar along with the close 'X' button
    # root.overrideredirect(True)

# SignIn button
button = Button(root, text="Sign In", command=signIn)
button.grid(row=1, column=0)

root.mainloop()

゛清羽墨安 2025-01-27 01:39:17

如果您想禁用最小化和最大化,请使用此功能。它将只剩下 x 按钮。我给出了仅删除最大化的示例,然后给出了同时删除最大化的示例。

import tkinter as tk
import time



root = tk.Tk()
root.geometry("500x500")
root.resizable(False, False)#removes only the maximize option

root.attributes("-toolwindow", True)#removes both the maximize and the minimize option


root.mainloop()

If you want to disable the minimize and maximize use this. It will leave you with only the x button. I gave example for only removing maximize and then one for both.

import tkinter as tk
import time



root = tk.Tk()
root.geometry("500x500")
root.resizable(False, False)#removes only the maximize option

root.attributes("-toolwindow", True)#removes both the maximize and the minimize option


root.mainloop()
痕至 2025-01-27 01:39:17

使用 root.wm_attributes('-type', '工具栏')

use root.wm_attributes('-type', 'toolbar')

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文