Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd302a1

Browse files
QuLogictacaswell
authored andcommitted
Backport PR#17565: FIX: support Qt 5.15
Merge pull request#17565 from tacaswell/fix_new_qtFIX: support Qt 5.15Conflicts:lib/matplotlib/backends/backend_qt5.py - code was very different, int cast done differently.
1 parentbd6fc99 commitcd302a1

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

‎lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def _draw_rect_callback(painter):
508508
pen=QtGui.QPen(QtCore.Qt.black,1/self._dpi_ratio,
509509
QtCore.Qt.DotLine)
510510
painter.setPen(pen)
511-
painter.drawRect(*(pt/self._dpi_ratioforptinrect))
511+
painter.drawRect(*(int(pt/self._dpi_ratio)forptinrect))
512512
else:
513513
def_draw_rect_callback(painter):
514514
return

‎lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,46 @@ def paintEvent(self, event):
3838
return
3939

4040
painter=QtGui.QPainter(self)
41-
42-
# See documentation of QRect: bottom() and right() are off by 1, so use
43-
# left() + width() and top() + height().
44-
rect=event.rect()
45-
# scale rect dimensions using the screen dpi ratio to get
46-
# correct values for the Figure coordinates (rather than QT5's coords)
47-
width=rect.width()*self._dpi_ratio
48-
height=rect.height()*self._dpi_ratio
49-
left,top=self.mouseEventCoords(rect.topLeft())
50-
# shift the "top" by the height of the image to get the
51-
# correct corner for our coordinate system
52-
bottom=top-height
53-
# same with the right side of the image
54-
right=left+width
55-
# create a buffer using the image bounding box
56-
bbox=Bbox([[left,bottom], [right,top]])
57-
reg=self.copy_from_bbox(bbox)
58-
buf=cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
59-
memoryview(reg))
60-
61-
# clear the widget canvas
62-
painter.eraseRect(rect)
63-
64-
qimage=QtGui.QImage(buf,buf.shape[1],buf.shape[0],
65-
QtGui.QImage.Format_ARGB32_Premultiplied)
66-
ifhasattr(qimage,'setDevicePixelRatio'):
67-
# Not available on Qt4 or some older Qt5.
68-
qimage.setDevicePixelRatio(self._dpi_ratio)
69-
# set origin using original QT coordinates
70-
origin=QtCore.QPoint(rect.left(),rect.top())
71-
painter.drawImage(origin,qimage)
72-
# Adjust the buf reference count to work around a memory
73-
# leak bug in QImage under PySide on Python 3.
74-
ifQT_APIin ('PySide','PySide2'):
75-
ctypes.c_long.from_address(id(buf)).value=1
76-
77-
self._draw_rect_callback(painter)
78-
79-
painter.end()
41+
try:
42+
# See documentation of QRect: bottom() and right() are off
43+
# by 1, so use left() + width() and top() + height().
44+
rect=event.rect()
45+
# scale rect dimensions using the screen dpi ratio to get
46+
# correct values for the Figure coordinates (rather than
47+
# QT5's coords)
48+
width=rect.width()*self._dpi_ratio
49+
height=rect.height()*self._dpi_ratio
50+
left,top=self.mouseEventCoords(rect.topLeft())
51+
# shift the "top" by the height of the image to get the
52+
# correct corner for our coordinate system
53+
bottom=top-height
54+
# same with the right side of the image
55+
right=left+width
56+
# create a buffer using the image bounding box
57+
bbox=Bbox([[left,bottom], [right,top]])
58+
reg=self.copy_from_bbox(bbox)
59+
buf=cbook._unmultiplied_rgba8888_to_premultiplied_argb32(
60+
memoryview(reg))
61+
62+
# clear the widget canvas
63+
painter.eraseRect(rect)
64+
65+
qimage=QtGui.QImage(buf,buf.shape[1],buf.shape[0],
66+
QtGui.QImage.Format_ARGB32_Premultiplied)
67+
ifhasattr(qimage,'setDevicePixelRatio'):
68+
# Not available on Qt4 or some older Qt5.
69+
qimage.setDevicePixelRatio(self._dpi_ratio)
70+
# set origin using original QT coordinates
71+
origin=QtCore.QPoint(rect.left(),rect.top())
72+
painter.drawImage(origin,qimage)
73+
# Adjust the buf reference count to work around a memory
74+
# leak bug in QImage under PySide on Python 3.
75+
ifQT_APIin ('PySide','PySide2'):
76+
ctypes.c_long.from_address(id(buf)).value=1
77+
78+
self._draw_rect_callback(painter)
79+
finally:
80+
painter.end()
8081

8182
defblit(self,bbox=None):
8283
# docstring inherited

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp