Created
February 16, 2019 15:30
-
-
Save cortical-iv/e100e0445f28cb0465b5441310fe7b4d to your computer and use it in GitHub Desktop.
Calculate dpi in scale-sensitive way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def get_dpi(screen_num = 0): | |
"""Calculate the dpi of a given monitor, sensitive to | |
scaling factors they have set.""" | |
from PyQt5.QtWidgets import QApplication | |
app = QApplication(sys.argv) | |
screen = app.screens()[screen_num] | |
dpi = screen.physicalDotsPerInch() | |
app.quit() | |
return dpi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment