Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Update pixmap height calculation #4738

Merged
merged 3 commits into from
Jul 26, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion spyder/widgets/sourcecode/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,12 @@ 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,
if is_pyqt46:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need

from qtpy import PYQT4, PYQT5

 if PYQT4:

https://github.com/spyder-ide/qtpy/blob/master/qtpy/__init__.py#L94

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, it needs to be more fine-grained because we support PyQt >=5.2. So the solution is something along the lines

from qtpy import QT_VERSION
QT55_VERSION = programs.check_version(QT_VERSION, "5.5", ">=")

if not QT55_VERSION:
    pixmap_height = pixmap.height()
else:
    ....

Of course, you need to add the imports and constants in the right places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the more fine grained option is now in there. Thanks for the help in knowing what to import.

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)

for top, line_number, block in self.visible_blocks:
Expand Down