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

Skip to content

Commit d27ad98

Browse files
committed
Fix rubberband removal in Qt backend
1 parent f744e7c commit d27ad98

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,9 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
681681
rect = [int(val)for val in (min(x0, x1), min(y0, y1), w, h)]
682682
self.canvas.drawRectangle(rect)
683683

684+
def remove_rubberband(self):
685+
self.canvas.drawRectangle(None)
686+
684687
def configure_subplots(self):
685688
image = os.path.join(matplotlib.rcParams['datapath'],
686689
'images', 'matplotlib.png')

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __init__(self, figure):
6767

6868
def drawRectangle(self, rect):
6969
self._drawRect = rect
70-
self.draw_idle()
70+
self.update()
7171

7272
def paintEvent(self, e):
7373
"""
@@ -136,9 +136,14 @@ def paintEvent(self, e):
136136
pixmap = QtGui.QPixmap.fromImage(qImage)
137137
p = QtGui.QPainter(self)
138138
p.drawPixmap(QtCore.QPoint(l, self.renderer.height-t), pixmap)
139+
140+
# draw the zoom rectangle to the QPainter
141+
if self._drawRect is not None:
142+
p.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.DotLine))
143+
x, y, w, h = self._drawRect
144+
p.drawRect(x, y, w, h)
139145
p.end()
140146
self.blitbox = None
141-
self._drawRect = None
142147

143148
def draw(self):
144149
"""

0 commit comments

Comments
 (0)