From edcf7cf13509994a55ffe671b10d2a69bbf22282 Mon Sep 17 00:00:00 2001 From: David Stauffer Date: Wed, 12 Jul 2017 17:16:43 -0700 Subject: [PATCH 1/3] Update pixmap height calculation --- spyder/widgets/sourcecode/codeeditor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spyder/widgets/sourcecode/codeeditor.py b/spyder/widgets/sourcecode/codeeditor.py index add6ddcf8ce..f856f3bac40 100644 --- a/spyder/widgets/sourcecode/codeeditor.py +++ b/spyder/widgets/sourcecode/codeeditor.py @@ -1179,7 +1179,8 @@ def linenumberarea_paint_event(self, event): active_line_number = active_block.blockNumber() + 1 def draw_pixmap(ytop, pixmap): - painter.drawPixmap(0, ytop + (font_height-pixmap.height()) / 2, + pixmap_height = pixmap.height() / pixmap.devicePixelRatio() + painter.drawPixmap(0, ytop + (font_height-pixmap_height) / 2, pixmap) for top, line_number, block in self.visible_blocks: From c625ffa9c77281b79406100d1d5992632e4b34e5 Mon Sep 17 00:00:00 2001 From: David Stauffer Date: Thu, 13 Jul 2017 14:59:31 -0700 Subject: [PATCH 2/3] Restore original behavior for PyQt4 --- spyder/widgets/sourcecode/codeeditor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spyder/widgets/sourcecode/codeeditor.py b/spyder/widgets/sourcecode/codeeditor.py index f856f3bac40..77828866d97 100644 --- a/spyder/widgets/sourcecode/codeeditor.py +++ b/spyder/widgets/sourcecode/codeeditor.py @@ -1179,7 +1179,11 @@ def linenumberarea_paint_event(self, event): active_line_number = active_block.blockNumber() + 1 def draw_pixmap(ytop, pixmap): - pixmap_height = pixmap.height() / pixmap.devicePixelRatio() + if is_pyqt46: + pixmap_height = pixmap.height() + else: + # scale pixmap height to device independent pixels + pixmap_height = pixmap.height() / pixmap.devicePixelRatio() painter.drawPixmap(0, ytop + (font_height-pixmap_height) / 2, pixmap) From 856705389665652c51db9250fc8e9df8acc06a81 Mon Sep 17 00:00:00 2001 From: David Stauffer Date: Fri, 14 Jul 2017 10:28:17 -0700 Subject: [PATCH 3/3] Check more specifically for QT >= 5.5 --- spyder/widgets/sourcecode/codeeditor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spyder/widgets/sourcecode/codeeditor.py b/spyder/widgets/sourcecode/codeeditor.py index 77828866d97..64101a9235f 100644 --- a/spyder/widgets/sourcecode/codeeditor.py +++ b/spyder/widgets/sourcecode/codeeditor.py @@ -27,7 +27,7 @@ import time # Third party imports -from qtpy import is_pyqt46 +from qtpy import is_pyqt46, QT_VERSION from qtpy.compat import to_qvariant from qtpy.QtCore import QRect, QRegExp, QSize, Qt, QTimer, Signal, Slot from qtpy.QtGui import (QBrush, QColor, QCursor, QFont, QIntValidator, @@ -52,6 +52,7 @@ from spyder.utils import syntaxhighlighters as sh from spyder.utils import encoding, sourcecode from spyder.utils.dochelpers import getobj +from spyder.utils.programs import check_version from spyder.utils.qthelpers import add_actions, create_action, mimedata2url from spyder.utils.sourcecode import ALL_LANGUAGES, CELL_LANGUAGES from spyder.widgets.editortools import PythonCFM @@ -68,6 +69,7 @@ # For debugging purpose: LOG_FILENAME = get_conf_path('codeeditor.log') DEBUG_EDITOR = DEBUG >= 3 +QT55_VERSION = check_version(QT_VERSION, "5.5", ">=") def is_letter_or_number(char): @@ -1179,7 +1181,7 @@ def linenumberarea_paint_event(self, event): active_line_number = active_block.blockNumber() + 1 def draw_pixmap(ytop, pixmap): - if is_pyqt46: + if not QT55_VERSION: pixmap_height = pixmap.height() else: # scale pixmap height to device independent pixels