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

remove .rect member (clashes with QWidget) #2946

Merged
merged 3 commits into from Apr 27, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/matplotlib/backends/backend_qt4agg.py
Expand Up @@ -68,14 +68,12 @@ def __init__(self, figure):
print('FigureCanvasQtAgg: ', figure)
FigureCanvasQT.__init__(self, figure)
FigureCanvasAgg.__init__(self, figure)
self.drawRect = False
self.rect = []
self._drawRect = None
self.blitbox = None
self.setAttribute(QtCore.Qt.WA_OpaquePaintEvent)

def drawRectangle(self, rect):
self.rect = rect
self.drawRect = True
self._drawRect = rect
self.repaint()

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

# draw the zoom rectangle to the QPainter
if self.drawRect:
if self._drawRect:
Copy link
Member

Choose a reason for hiding this comment

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

Can you change this to if self._drawRect is not None: ? I know that it is valid and correct python as-written, however I think it is clearer to do the conversion to bool explicitly.

p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
p.drawRect(self.rect[0], self.rect[1],
self.rect[2], self.rect[3])
x, y, w, h = self._drawRect
p.drawRect(x, y, w, h)
p.end()

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

def draw(self):
"""
Expand Down