views:

222

answers:

1

Is there a cross platform way to get the monitor's refresh rate in python (2.6)? I'm using Pygame and PyOpenGL, if that helps.

I don't need to change the refresh rate, I just need to know what it is.

+1  A: 

I am not sure about the platform you use, but on window you can use ctypes or win32api to get details about devices e.g. using win32api

import win32api

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

device = win32api.EnumDisplayDevices()
printInfo(device)

output on my system:

\\.\DISPLAY1 Mobile Intel(R) 945GM Express Chipset Family
Color: 0
BitsPerPel: 8
DisplayFrequency: 60
Anurag Uniyal