Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Fix rubberband removal in Qt backend
  • Loading branch information
pwuertz committed Aug 27, 2015
commit d27ad9832fbf59613b6fae5787323c6caa49d5ff
3 changes: 3 additions & 0 deletions lib/matplotlib/backends/backend_qt5.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
rect = [int(val)for val in (min(x0, x1), min(y0, y1), w, h)]
self.canvas.drawRectangle(rect)

def remove_rubberband(self):
self.canvas.drawRectangle(None)

def configure_subplots(self):
image = os.path.join(matplotlib.rcParams['datapath'],
'images', 'matplotlib.png')
Expand Down
9 changes: 7 additions & 2 deletions lib/matplotlib/backends/backend_qt5agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(self, figure):

def drawRectangle(self, rect):
self._drawRect = rect
self.draw_idle()
self.update()

def paintEvent(self, e):
"""
Expand Down Expand Up @@ -136,9 +136,14 @@ def paintEvent(self, e):
pixmap = QtGui.QPixmap.fromImage(qImage)
p = QtGui.QPainter(self)
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)

# draw the zoom rectangle to the QPainter
if self._drawRect is not None:
p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
x, y, w, h = self._drawRect
p.drawRect(x, y, w, h)
p.end()
self.blitbox = None
self._drawRect = None

def draw(self):
"""
Expand Down