使用 Tk 的全屏模式

发布于 2024-09-18 09:31:35 字数 40 浏览 2 评论 0原文

是否可以在 Tk 应用程序中创建某种全屏模式(例如无窗口标题栏)?

Is it possible to create some kind of fullscreen mode (e.g. no window title bar) in Tk applications?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

來不及說愛妳 2024-09-25 09:31:35

我曾经在代码中使用 wm overrideredirect 技巧。最近我发现它在 Ubuntu 上有 bug。不知道为什么,也许是 gnome 问题,也许是 glx 问题。目前我正在使用:

wm attributes . -fullscreen 1

到目前为止,它可以在 Windows 和 Linux 上运行。还没有在 Mac 上测试过,但我不明白为什么它不起作用。


好的,阅读手册页。据说它可以在 Windows、OSX (Quartz) 和 X11 上运行。


为那些不相信我的人提供的附加信息

手册页说:

 -fullscreen
         Places the window in a mode  that  takes  up  the  entire
         screen,  has  no borders, and covers the general use area
         (i.e. Start menu and taskbar on Windows, dock and menubar
         on OSX, general window decorations on X11).

这似乎暗示窗口装饰(标题栏等)在-fullscreen 模式下被删除。根据我的实际经验(我刚刚在 2 秒前检查了我的代码),Windows 和 Ubuntu (linux) 上似乎就是这种情况。不知道 OSX 是否如此,但手册页说应该如此。

如果这在任何平台上都不是这样,那么我相信这是文档中的错误。在这种情况下,应该在手册页中清楚地注明哪些平台上的窗口装饰未被删除。

I used to use the wm overrideredirect trick in my code. Recently I found it to be buggy on Ubuntu. Not sure why, maybe a gnome issue, maybe a glx issue. Currently I'm using:

wm attributes . -fullscreen 1

which so far works on Windows and Linux. Haven't tested on Mac although I don't see why it wouldn't work.


OK read the man page. It says it works on Windows, OSX (Quartz) and X11.


Additional info

for those who didn't believe me

The man page says:

 -fullscreen
         Places the window in a mode  that  takes  up  the  entire
         screen,  has  no borders, and covers the general use area
         (i.e. Start menu and taskbar on Windows, dock and menubar
         on OSX, general window decorations on X11).

which seems to imply that the window decorations (title bar etc) is removed in -fullscreen mode. And in my real-world experience (I just checked my code 2 seconds ago) that seems to be the case on Windows and Ubuntu (linux). Don't know if it's true for OSX but the man page says it should be.

If this is ever not true on any platform then I believe it is a bug in the documentation. In which case it should be noted in the man page clearly on which platform are window decorations not removed.

仅一夜美梦 2024-09-25 09:31:35

是的。您想要在顶层设置 overrideredirect 标志。

toplevel .top
wm overrideredirect .top 1

如果您以交互方式运行此命令,则需要撤回窗口并取消图标化,以便窗口管理器有机会从窗口中删除框架。

这只会删除窗口管理器装饰。您需要以正常方式将大小作为单独的步骤进行管理。

有关详细信息,请参阅 wm 命令的手册页

Yes. You wan to set the overrideredirect flag on a toplevel.

toplevel .top
wm overrideredirect .top 1

If you run this interactively you need to withdraw the window and them deiconify it so that the window manager has a chance to remove the frame from the window.

This only removes the window manager decorations. You need to manage the size as a separate step in the normal way.

For more information see the man page on the wm command

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文