简体   繁体   English

我将如何制作一个无法在 Python Tkinter 中最小化的 tk 窗口?

[英]How will I make a tk window which cannot be minimized in Python Tkinter?

I tried win.overrideredirect(True) it didn't work...我试过win.overrideredirect(True)它没有用...

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规格:Python 3.9.6 [最新],Pip 21.1.3,操作系统:Windows 10 Home

I want to make the minimize button to be disabled... Please help我想让最小化按钮被禁用...请帮忙

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()

try resizeable function like this :尝试像这样调整大小的功能:

win= Tk()

win.geometry("750x250")

win.resizable(False, False)

The thing @N1CK145 posted didn't work for me but I am guessing that he/she tried to do this: @N1CK145 发布的内容对我不起作用,但我猜他/她试图这样做:

import Tkinter as tk

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

If you want to know more attribute options look here如果您想了解更多attribute选项,请看这里

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

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