Update qt screen script to new import schema

update_qt_screen_info_script
Tyler Goodlet 2023-02-02 14:24:41 -05:00
parent f31bd42a19
commit d2e21f45b2
1 changed files with 12 additions and 7 deletions

View File

@ -16,12 +16,16 @@ DPI and info helper script for display metrics.
from pyqtgraph import ( from pyqtgraph import (
QtGui, QtGui,
QtWidgets,
) )
from PyQt5.QtCore import ( from PyQt5.QtCore import (
Qt, Qt,
QCoreApplication, QCoreApplication,
) )
from PyQt5.QtWidgets import (
QWidget,
QMainWindow,
QApplication,
)
# Proper high DPI scaling is available in Qt >= 5.6.0. This attibute # Proper high DPI scaling is available in Qt >= 5.6.0. This attibute
# must be set before creating the application # must be set before creating the application
@ -32,9 +36,9 @@ if hasattr(Qt, 'AA_UseHighDpiPixmaps'):
QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True) QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)
app = QtWidgets.QApplication([]) app = QApplication([])
window = QtWidgets.QMainWindow() window = QMainWindow()
main_widget = QtWidgets.QWidget() main_widget = QWidget()
window.setCentralWidget(main_widget) window.setCentralWidget(main_widget)
window.show() window.show()
@ -46,7 +50,7 @@ pxr = main_widget.devicePixelRatioF()
# screen = app.screens()[screen_num] # screen = app.screens()[screen_num]
def ppscreeninfo(screen: 'QScreen') -> None: def ppscreeninfo(screen: QtGui.QScreen) -> None:
# screen_num = app.desktop().screenNumber() # screen_num = app.desktop().screenNumber()
name = screen.name() name = screen.name()
size = screen.size() size = screen.size()
@ -68,6 +72,7 @@ def ppscreeninfo(screen: 'QScreen') -> None:
print('-'*50 + '\n') print('-'*50 + '\n')
screen = app.screenAt(main_widget.geometry().center()) screen = app.screenAt(main_widget.geometry().center())
ppscreeninfo(screen) ppscreeninfo(screen)