Query screen resolution?

Nobody nobody at nowhere.com
Sat Aug 29 04:06:03 CEST 2009


On Fri, 28 Aug 2009 11:13:06 -0700, AK Eric wrote:

> Thought this would be easy, maybe I'm missing something :)  Trying to
> query the x,y resolution of my screen.  I've seen this available
> through http://python.net/crew/mhammond/win32/ :
> 
> from win32api import GetSystemMetrics
> print "width =", GetSystemMetrics (0)
> print "height =",GetSystemMetrics (1)
> 
> But I was hoping for something built-in, and something non-OS
> specific.  Is that available?  Would be nice to detect for multiple
> monitors as well, but I'm probably asking too much :)

Your question is based upon the notion that "the screen" is a meaningful
concept. Once you move away from Windows (and systems which intentionally
try to be like Windows), that's no longer true.

E.g. if the program is being run on a terminal, the screen size is
measured in characters, not pixels (80x25 would be a reasonable size). If
the program is being run as a cron job or CGI script, there is no screen.

OTOH, if the system has the X libraries installed, there are a practically
unlimited number of X displays which you could connect to, provided that
you have the appropriate authentication credentials.




More information about the Python-list mailing list