Is there a equatable bit of code to GetSystemMetrics in win32api, for Ubuntu? I need to get the monitors width and height in pixels.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With