python - 退出全屏时 Tkinter 应用程序消失

标签 python ubuntu tkinter fullscreen

我有一个 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/

相关文章:

python - 用 pandas 填充最后已知的数据

python - 如何使用 Autokey 移动应用程序窗口?

linux - 消除 VirtualBox 上的 emacs 中的 "File changed on disk"警告

PHP MySQL 选择长度错误

python - Tkinter Radiobutton 中指定宽度的垂直对齐字符串

python - 将 eventlet 与 SQLAlchemy 一起使用

python - 带距离查找的 Geodjango 查询

php - Godaddy Ubuntu 3.6 mod_rewrite 问题

python - 使用 Tkinter 文本编辑器突出显示错误

python - Tkinter 启动画面和主循环外的多处理