Skip to content

Commit

Permalink
Fixed QApplication.desktop AttributeError
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreRaybaut committed Oct 16, 2023
1 parent 0e6ea01 commit 2eb2c34
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions qwt/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@
import os
import struct

from qtpy.QtCore import QRectF, QSize, QSizeF, Qt
from qtpy.QtGui import (
QPainter,
QPalette,
QAbstractTextDocumentLayout,
QColor,
QFont,
QFontInfo,
QFontMetrics,
QColor,
QTextDocument,
QTextOption,
QFontMetricsF,
QPainter,
QPalette,
QPixmap,
QFontInfo,
QTextDocument,
QTextOption,
QTransform,
QAbstractTextDocumentLayout,
)
from qtpy.QtWidgets import QFrame, QWidget, QSizePolicy, QApplication
from qtpy.QtCore import Qt, QSizeF, QSize, QRectF
from qtpy.QtWidgets import QApplication, QFrame, QSizePolicy, QWidget

from qwt.painter import QwtPainter
from qwt.qthelpers import qcolor_from_str
Expand Down Expand Up @@ -206,7 +206,10 @@ def qwtUnscaleFont(painter):
dpix, dpiy = get_screen_resolution()
pd = painter.device()
if pd.logicalDpiX() != dpix or pd.logicalDpiY() != dpiy:
pixelFont = QFont(painter.font(), QApplication.desktop())
try:
pixelFont = QFont(painter.font(), QApplication.desktop())
except AttributeError:
pixelFont = QFont(painter.font())
pixelFont.setPixelSize(QFontInfo(pixelFont).pixelSize())
painter.setFont(pixelFont)

Expand Down

0 comments on commit 2eb2c34

Please sign in to comment.