在pygtk中检测全屏

发布于 2024-10-14 09:59:03 字数 157 浏览 3 评论 0原文

我希望能够检测用户是否已将我的应用程序设置为全屏。我知道我可以使用 gtk.window.fullscreen() 方法使窗口从代码变为全屏,并且该操作还会发出窗口状态事件信号,但是当我编写回调 我无法区分事件是由全屏请求激活还是由不同事件激活,例如最小化窗口到开始栏。如何检测窗口是否已更改为全屏?

I want to be able to detect if my app has been set to fullscreen by the user. I know I can use the gtk.window.fullscreen() method to make the window go fullscreen from the code, and the the action also emits a window-state-event signal, but when I wrote the callback I had no way of distinguishing between when the event was activated by a fullscreen request or by a different event like for example minimizing the window to the start bar. How can I detect whether the window has been changed to full screen?

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

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

发布评论

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

评论(1

十年九夏 2024-10-21 09:59:03

您只需检查事件详细信息

  • 要查看触发事件的用户操作,请检查 changed_mask
  • 要查看新状态(无论导致事件的原因是什么),请检查 new_window_state

通常这会翻译成以下代码:

# Did the user actually toggle fullscreen, or was it
# a different window-state event (e.g. maximize)?
if event.changed_mask & gtk.gdk.WINDOW_STATE_FULLSCREEN:
    # What's the new state?
    print bool(event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN)

You just need to check the event details.

  • To see what user action triggers the event, check changed_mask.
  • To see the new state (regardless of what causes the event), check new_window_state.

Usually this translates into the following code:

# Did the user actually toggle fullscreen, or was it
# a different window-state event (e.g. maximize)?
if event.changed_mask & gtk.gdk.WINDOW_STATE_FULLSCREEN:
    # What's the new state?
    print bool(event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文