Is there a equatable bit of code to GetSystemMetrics in win32api, for Ubuntu? I need to get the monitors width and height in pixels.
+1
A:
I can suggest a few approaches that can be used. I have not used the xlib version though.
1) xlib ( X client library for Python programs), if available on your system. You can look at "Display" methods and properties : python-xlib.sourceforge
2) On Ubuntu, you could do the following to get the screen resolution:
xrandr | grep \* | cut -d' ' -f4
3) You can use subprocess python module, to run the above command and extract the information
import subprocess
output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
print output
Let me know, if this was helpful to you.
pyfunc
2010-08-30 06:25:24
+2
A:
I assume you're a GUI toolkit. Why else would you be interested in the screen dimensions?
Check out gtk.gdk.screen_width()
and gtk.gdk.screen_height()
from PyGTK. Something similar should be available for QT.
loevborg
2010-08-30 07:33:43
With wxPython, it would be the GetDisplaySize method: http://xoomer.virgilio.it/infinity77/wxPython/wxFunctions.html?highlight=getdisplaysize#GetDisplaySize
Mark
2010-08-30 14:02:16
Thanks, I'm currently re-configuring some of my programs to run in Ubuntu. I'm switching out all the Win specific functions.
Anteater7171
2010-08-30 18:23:22