What is the simplest way to get monitor resolution (Preferably in a tuple)?
+5
A:
from win32api import GetSystemMetrics
print "width =", GetSystemMetrics (0)
print "height =",GetSystemMetrics (1)
From: http://bytes.com/topic/python/answers/618587-screen-size-resolution-win32-python
Robus
2010-06-27 23:41:32
Awesome exactly what I was looking for!
Anteater7171
2010-06-28 03:56:29
+2
A:
Using Linux, the simplest way is to execute bash command
xrandr | grep '*'
and parse its output using regexp.
Also you can do it through PyGame: http://www.daniweb.com/forums/thread54881.html
Riateche
2010-06-27 23:53:58
+7
A:
If you're using wxWindows, it's:
import wx
wx.App(False) # The wx.App object must be created first!
print wx.GetDisplaySize()
(returns a tuple).
Ned Batchelder
2010-06-28 00:42:33
+6
A:
In Windows, you can also use ctypes:
import ctypes
user32 = ctypes.windll.user32
screensize = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
so that you don't need to install the pywin32 package; it doesn't need anything that doesn't come with Python itself.
jcao219
2010-06-28 00:54:26
+5
A:
And for completeness, Mac OS X
import AppKit
[(screen.frame().size.width, screen.frame().size.height)
for screen in AppKit.NSScreen.screens()]
will give you a list of tuples containing all screen sizes (if multiple monitors present)
cobbal
2010-06-28 01:09:39