python - 读取 pygame 显示的当前标志(全屏等)

标签 python python-3.x pygame display

是否可以读取显示器给出的当前标志?因此,当有人调用 pygame.display.set_mode(resolution, FLAGS) 时,我很乐意随后阅读它们。

例如,我想要一个 is_fullscreen() 函数。

最佳答案

您正在寻找pygame.Surface.get_flags方法。

Returns a set of current Surface features. Each feature is a bit in the flags bitmask.

pygame.display.set_mode返回一个 pygame.Surface。因此,请调用显示器的 get_flags 方法,并将其与特定标志进行按位与。

def is_fullscreen(display):
    return bool(display.get_flags() & pygame.FULLSCREEN)

关于python - 读取 pygame 显示的当前标志(全屏等),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49929284/

相关文章:

python - 如何从多个列表生成字典?

python - pygame.错误: Invalid joystick device number

python - 单元测试 - 模拟/抑制对象的 __init__

python - Django View : How to display data from a dictionary

python - 为什么 eval ("assert(True)") 在 python 中失败?

c - 我找不到 python35_d.lib

python-3.x - Pytest 使用装置比较几个类实例

python - 一起使用 Tkinter 和 pygame 有什么我需要知道的吗?

python - 如何获取 pygame 窗口的大小(宽度 x 高度)

Python正则表达式从字符串中提取版本