Skip to content

Commit ab481d6

Browse files
committed
remove .rect member (clashes with QWidget)
FigureCanvasQTAgg inherits from QWidget, which already has a 'rect' property and getter. Also, consolidate .rect and (boolean) .drawRect into a single _drawRect member. This is only used for the zoom rect and not accessed from other classes (other than indirectly via the drawRectangle() function).
1 parent b8cb6c3 commit ab481d6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/matplotlib/backends/backend_qt4agg.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@ 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

7675
def drawRectangle(self, rect):
77-
self.rect = rect
78-
self.drawRect = True
76+
self._drawRect = rect
7977
self.repaint()
8078

8179
def paintEvent(self, e):
@@ -115,10 +113,10 @@ def paintEvent(self, e):
115113
p.drawPixmap(QtCore.QPoint(0, 0), QtGui.QPixmap.fromImage(qImage))
116114

117115
# draw the zoom rectangle to the QPainter
118-
if self.drawRect:
116+
if self._drawRect:
119117
p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
120-
p.drawRect(self.rect[0], self.rect[1],
121-
self.rect[2], self.rect[3])
118+
x, y, w, h = self._drawRect
119+
p.drawRect(x, y, w, h)
122120
p.end()
123121

124122
# This works around a bug in PySide 1.1.2 on Python 3.x,
@@ -143,7 +141,7 @@ def paintEvent(self, e):
143141
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
144142
p.end()
145143
self.blitbox = None
146-
self.drawRect = False
144+
self._drawRect = None
147145

148146
def draw(self):
149147
"""

0 commit comments

Comments
 (0)