Resize display resolution using a python function. It should be cross platform, ie support for windows, linux and mac (it is okay to have multiple cases depending on the operating system)
I have code which I think works on linux (Ubuntu) I am looking for a solution for windows and mac (should support both 32 and 64 bit machines)
def SetResolution(width, height):
os.popen("xrandr -s "+str(width)+'x'+str(height))
I would also appreciate it if somebody could tell me how I could get the possible display resolutions for windows and mac
my function on linux is this:
def GetResolutions():
screen = os.popen("xrandr").readlines()
possibleResolutions = []
for a in screen:
data = a.split()
if len(data)<4:
width, height = data[0].split('x')
fps = re.sub("[^0-9.]", "", data[1])
possibleResolutions.append({'width':int(width),'height':int(height),'fps':float(fps)})
if '*' in data[1]:
currentResolution = {'width':int(width),'height':int(height),'fps':float(fps)}
return possibleResolutions, currentResolution