Linux 带 Tk 的全屏模式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3677010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 23:08:27  来源:igfitidea点击:

Fullscreen mode with Tk

tcltk

提问by Karsten W.

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

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

采纳答案by slebetman

I used to use the wm overrideredirecttrick 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 overrideredirect在我的代码中使用过这个技巧。最近我发现它在 Ubuntu 上有问题。不知道为什么,可能是 gnome 问题,也可能是 glx 问题。目前我正在使用:

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.

到目前为止,它适用于 Windows 和 Linux。没有在 Mac 上测试过,虽然我不明白为什么它不起作用。



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

好的阅读手册页。它说它适用于 Windows、OSX (Quartz) 和 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 -fullscreenmode. 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.

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

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.

如果这在任何平台上都不是真的,那么我相信这是文档中的错误。在这种情况下,应该在手册页中清楚地指出在哪个平台上没有删除窗口装饰。

回答by Bryan Oakley

Yes. You wan to set the overrideredirectflag on a toplevel.

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

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 wmcommand

有关更多信息,请参阅wm命令的手册页