我有一个 python tkinter 应用程序,并希望在启动它时全屏显示它(如果重要的话,在 Ubuntu 中)。所以我用了Tk.attributes('-zoomed', True)
.如果我用鼠标将窗口拉出全屏,它就会消失。我仍然可以看到应用程序的图标 - 所以它仍然处于打开状态 - 但我只能看到我的空桌面并且单击图标也不使其可见。
当我用 Tk.geometry('1500x800')
定义窗口大小时,然后让它全屏并再次退出全屏,就像它没有消失之前一样。
这可能是什么原因?
提前致谢。
编辑:对不起,我从内存中写了这个问题,自从我写了这个问题以来,我已经过了一段时间,Tk 不是我真正的变量名。这是实际的代码:
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# Set the window's size
self.geometry('1500x800') # set size manually
# self.attributes('-zoomed', True) # fullscreen with toolbar
# self.attributes('-fullscreen', True) # fullscreen
...
最佳答案
If you want to set the fullscreen attribute to True, it is as easy as:
root = Tk()
root.attributes('-fullscreen', True)
However, it doesn't show the title bar. If you want to keep it visible, you can resize the Tk element with the geometry() method:
root = Tk()
w, h = root.winfo_screenwidth(), root.winfo_screenheight()
root.geometry("%dx%d+0+0" % (w, h))
关于python - 退出全屏时 Tkinter 应用程序消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64925294/