是否有一种跨平台的方法可以在 python (2.6) 中获取显示器的刷新率?如果有帮助,我正在使用 Pygame 和 PyOpenGL。
我不需要更改刷新率,我只需要知道它是什么。
最佳答案
我不确定您使用的平台,但在窗口上您可以使用 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)
我的系统输出:
\\.\DISPLAY1 Mobile Intel(R) 945GM Express Chipset Family
Color: 0
BitsPerPel: 8
DisplayFrequency: 60
关于python - 如何确定显示器刷新率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1225057/