Skip to content

Commit 4edc4c2

Browse files
committed
Merge pull request #2946 from hmeine/fix_rect_clash
remove .rect member (clashes with QWidget)
2 parents 6ddf5c0 + 1e73388 commit 4edc4c2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

doc/api/api_changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ original location:
138138
* Removed the class `FigureManagerQTAgg` and deprecated `NavigationToolbar2QTAgg`
139139
which will be removed in 1.5.
140140

141+
* Removed formerly public (non-prefixed) attributes `rect` and
142+
`drawRect` from `FigureCanvasQTAgg`; they were always an
143+
implementation detail of the (preserved) `drawRectangle()` function.
144+
141145
* The function signatures of `tight_bbox.adjust_bbox` and
142146
`tight_bbox.process_figure_for_rasterizing` have been changed. A new
143147
`fixed_dpi` parameter allows for overriding the `figure.dpi` setting

lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ def __init__(self, figure):
6868
print('FigureCanvasQtAgg: ', figure)
6969
FigureCanvasQT.__init__(self, figure)
7070
FigureCanvasAgg.__init__(self, figure)
71-
self.drawRect = False
72-
self.rect = []
71+
self._drawRect = None
7372
self.blitbox = None
7473
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)
7574
# it has been reported that Qt is semi-broken in a windows
@@ -90,8 +89,7 @@ def __init__(self, figure):
9089
self._priv_update = self.update
9190

9291
def drawRectangle(self, rect):
93-
self.rect = rect
94-
self.drawRect = True
92+
self._drawRect = rect
9593
self.repaint()
9694

9795
def paintEvent(self, e):
@@ -131,10 +129,10 @@ def paintEvent(self, e):
131129
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))
132130

133131
# draw the zoom rectangle to the QPainter
134-
if self.drawRect:
132+
if self._drawRect is not None:
135133
p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
136-
p.drawRect(self.rect[0], self.rect[1],
137-
self.rect[2], self.rect[3])
134+
x, y, w, h = self._drawRect
135+
p.drawRect(x, y, w, h)
138136
p.end()
139137

140138
# This works around a bug in PySide 1.1.2 on Python 3.x,
@@ -159,7 +157,7 @@ def paintEvent(self, e):
159157
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
160158
p.end()
161159
self.blitbox = None
162-
self.drawRect = False
160+
self._drawRect = None
163161

164162
def draw(self):
165163
"""

0 commit comments

Comments
 (0)