如何确定显示器的刷新率?

Bra*_*eis 8 python pygame pyopengl

有没有跨平台的方法来获取Python(2.6)中显示器的刷新率?我正在使用 Pygame 和 PyOpenGL,如果有帮助的话。

我不需要改变刷新率,我只需要知道它是什么。

Anu*_*yal 11

我不确定您使用的平台,但在窗口上您可以使用 ctypes 或 win32api 来获取有关设备的详细信息,例如使用 win32api

import win32api

def printInfo(device):
    print((device.DeviceName, device.DeviceString))
    settings = win32api.EnumDisplaySettings(device.DeviceName, -1)
    for varName in ['Color', 'BitsPerPel', 'DisplayFrequency']:
        print("%s: %s"%(varName, getattr(settings, varName)))

device = win32api.EnumDisplayDevices()
printInfo(device)
Run Code Online (Sandbox Code Playgroud)

我的系统上的输出:

\\.\DISPLAY1 Mobile Intel(R) 945GM Express Chipset Family
Color: 0
BitsPerPel: 8
DisplayFrequency: 60
Run Code Online (Sandbox Code Playgroud)