Получить DPI экрана с помощью Python - PullRequest
0 голосов
/ 08 января 2020

Я пытаюсь получить физический размер монитора. Я могу получить разрешение, и я хочу найти DPI экрана. Есть ли простой способ в Python для этого?

Машина: Raspberry Pi

Код для поиска разрешения:

import subprocess

def get_dpi:
   #...code for finding dpi
   return dpi

output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
resolution = output.split()[0].split(b'x')
screenWidth =  int(resolution[0].decode('utf-8'))
screenHeight =  int(resolution[1].decode('utf-8'))

screenDpi = get_dpi()

#print(screenWidth,screenDpi)
# get actual screen width and height in inches
physicalWidth = screenWidth/screenDpi 
physicalHeight = physicalHeight/screenDpi 
print(physicalWidth, physicalHeight)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...