使用 Tkinter 删除没有 overrideredirect() 的标题栏? [英] Remove titlebar without overrideredirect() using Tkinter?

查看:183
本文介绍了使用 Tkinter 删除没有 overrideredirect() 的标题栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在 Linux 上使用 Tkinter 和 Python 2.7,我想知道是否有办法删除 TK() 窗口边框和标题栏而不使用 overrideredirect(1).

I'm currently working with Tkinter and Python 2.7 on Linux and I was wondering if there was a way to remove the TK() window border frame and title bar without using overrideredirect(1).

我有自己的关闭按钮,overrideredirect(1) 出现了一些我无法接受的问题:

I have my own close button and overrideredirect(1) presents me with a few issues that I can't accept:

我不能使用 attributes("-fullscreen", True) 作为标题栏和边框保留.

I can't use attributes("-fullscreen", True) as the titlebar and borders remain.

推荐答案

窗口装饰都是由窗口管理器处理的,所以你要做的是找到一种方法来告诉窗口管理器以不同的方式装饰你的窗口标准应用程序窗口.Tk 提供了 overrideredirect 来让窗口管理器完全忽略这个窗口,但我们也可以使用 扩展窗口管理器提示 向窗口管理器声明此顶级窗口的预期用途.例如,这是为工具提示和闪屏窗口完成的,以允许管理器提供最少的装饰和可能的特殊动画.

The window decoration is all handled by the window manager so what you are trying to do is find a way to tell the window manager to decorate your window differently from a standard application window. Tk provides overrideredirect to have the window manager completely ignore this window but we can also use Extended Window Manager Hints to declare the intended use of this toplevel window to the window manager. This is done for instance for tooltip and splashscreen windows to allow the manager to provide minimal decoration and possibly special animations.

在您的情况下,添加飞溅"提示应该可以满足您的需求

In your case, adding a 'splash' hint should do what you want

root = tk.Tk()
root.wm_attributes('-type', 'splash')

为此,您需要 Tk 8.5 或更高版本.

You will need Tk 8.5 or above for this.

这篇关于使用 Tkinter 删除没有 overrideredirect() 的标题栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆