高分辨率屏幕上的PyQt GUI大小 [英] PyQt GUI size on high resolution screens
问题描述
我不久前发布了问题询问有关Tkinter后端的信息,但后来却忘记了,但后来我意识到我正在使用pyqt后端.有解决办法吗?
I posted a question a while ago asking about Tkinter backends and subsequently forgot about it but I've since realised that I'm using the pyqt backend. Is there a fix for that?
原始问题:
因此,看来matplotlib gui图(la plt.show())不适应监视器分辨率,并且在高分辨率屏幕上显得很小.是否有matplotlib + Pyqt修复程序,或者我在Windows设置中的某个地方摆弄了东西?
So it appears that matplotlib gui plots (a la plt.show()) don't adapt to monitor resolution and appear tiny on high resolution screens. Is there a matplotlib+Pyqt fix or do I have fiddle around somewhere in Windows settings?
谢谢
推荐答案
在加载应用之前,而不是加载时.
Before app is loaded, and not while loading.
插入:
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
像这样:
import PyQt5
from PyQt5 import QtCore, QtGui, uic, QtWidgets
from PyQt5.QtWidgets import QWidget
if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)
if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)
class MyWindow(PyQt5.QtWidgets.QMainWindow):
def __init__(self):
super(MyWindow, self).__init__()
如果仍然无法使用,请使用用户en var,而不是system en var.
And if that still don't work, in user en var and not system en var.
QT_AUTO_SCREEN_SCALE_FACTOR=2
这篇关于高分辨率屏幕上的PyQt GUI大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!