def get_monitor_geometries(): ensure_app_is_running() monitor_geometries = {} desktop = QtGui.QDesktopWidget() for screenx in range(desktop.numScreens()): rect = desktop.availableGeometry(screen=screenx) geom = (rect.x(), rect.y(), rect.width(), rect.height()) monitor_geometries[screenx] = geom return monitor_geometries
def get_resolution_info(monitor_num=0): r""" Args: monitor_num (int): (default = 0) Returns: dict: info CommandLine: python -m plottool.screeninfo get_resolution_info --show Example: >>> # DISABLE_DOCTEST >>> from plottool.screeninfo import * # NOQA >>> monitor_num = 0 >>> info = get_resolution_info(monitor_num) >>> print('info = %s' % (ut.repr2(info, nl=True),)) >>> info = get_resolution_info(1) >>> print('info = %s' % (ut.repr2(info, nl=True),)) """ ensure_app_is_running() desktop = QtGui.QDesktopWidget() screen = desktop.screen(monitor_num) ppi_x = screen.logicalDpiX() ppi_y = screen.logicalDpiY() dpi_x = screen.physicalDpiX() dpi_y = screen.physicalDpiY() rect = desktop.availableGeometry(screen=monitor_num) pixels_w = rect.width() pixels_h = rect.height() inches_w = (pixels_w / dpi_x) inches_h = (pixels_h / dpi_y) #pixel_density = dpi_x / ppi_x info = { 'monitor_num': monitor_num, 'ppi_x': ppi_x, 'ppi_y': ppi_y, 'dpi_x': dpi_x, 'dpi_y': dpi_y, #'pixel_density': pixel_density, 'inches_w': inches_w, 'inches_h': inches_h, 'pixels_w': pixels_w, 'pixels_h': pixels_h, } return info
def get_monitor_geom(monitor_num=0): r""" Args: monitor_num (int): (default = 0) Returns: tuple: geom CommandLine: python -m plottool.screeninfo get_monitor_geom --show Example: >>> # DISABLE_DOCTEST >>> from plottool.screeninfo import * # NOQA >>> monitor_num = 0 >>> geom = get_monitor_geom(monitor_num) >>> result = ('geom = %s' % (ut.repr2(geom),)) >>> print(result) """ ensure_app_is_running() desktop = QtGui.QDesktopWidget() rect = desktop.availableGeometry(screen=monitor_num) geom = (rect.x(), rect.y(), rect.width(), rect.height()) return geom