【问题标题】:pyglet resolution of screen into variables屏幕的pyglet分辨率成变量
【发布时间】:2016-07-05 13:13:02
【问题描述】:

是否有任何选项如何使用 pyglet 将屏幕的值 heightwidth 获取到变量中?我可以打印它,但不能提取这些值。

import pyglet

platform = pyglet.window.get_platform()
display = platform.get_default_display()
screen = display.get_screens()

->

>>> screen
[XlibScreen(display=<pyglet.canvas.xlib.XlibDisplay object at 0x7f4644cf0990>, x=0, y=0, width=1366, height=768, xinerama=0)]
>>> 

有什么想法吗?提前致谢。

【问题讨论】:

    标签: python-2.7 screen-resolution pyglet


    【解决方案1】:

    应该这么简单:

    platform = pyglet.window.get_platform()
    display = platform.get_default_display()      
    screen = display.get_default_screen()
    screen_width = screen.width
    screen_height = screen.height
    

    【讨论】:

    • 是的,现在我明白了。谢谢!!
    【解决方案2】:

    pyglet pyglet.window.get_platform() 的新版本中已弃用/删除proof
    因此代码将如下所示:

        display = pyglet.canvas.Display()
        screen = display.get_default_screen()
        screen_width = screen.width
        screen_height = screen.height
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-06-28
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      相关资源
      最近更新 更多