[英]How do i minimise a Tkinter window
Im trying to make the user use fullscreen then have the ability to minimise their screen, is there a way to do that in Tkinter?我试图让用户使用全屏然后能够最小化他们的屏幕,有没有办法在 Tkinter 中做到这一点? this is my code for the main window
这是我的主要代码 window
def home():
mainbody = Tk() # main body
mainbody.geometry("1300x800") # size of window
mainframe = Frame(mainbody)
mainframe.grid()
Button(mainframe, bg="RoyalBlue2", width=12, text="Desktop", command=desktop).grid(row=0, column=0)
and i want the user to be able to press "Desktop" which will minimise the window without to press a button to go back to full screen or atleast a larger size我希望用户能够按下“桌面”,这将最小化 window 而无需按下按钮 go 回到全屏或至少更大的尺寸
def desktop():
goodbye_screen = Tk()
goodbye_screen.geometry("300x300")
Label(goodbye_screen, text="Goodbye!").grid()
goodbye_screen.withdraw()
Here is a quick solution I made for your problem.这是我为您的问题制定的快速解决方案。 Also, I don't know if you intended to do this but if you keep on repeating
(variable) = Tk()
, the windows are going to conflict.另外,我不知道您是否打算这样做,但是如果您继续重复
(variable) = Tk()
,则 windows 将会发生冲突。
from tkinter import *
window = Tk()
def desktop():
Label(window, text="Goodbye!").grid()
window.wm_state('iconic')
def home():
window.geometry("1300x800") # size of window
mainframe = Frame(window)
mainframe.grid()
Button(mainframe, bg="RoyalBlue2", width=12, text="Desktop", command=desktop).grid(row=0, column=0)
home()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.