8000 Restored 'draw_idle' method to allow for mpl callbacks to finish proc… · matplotlib/matplotlib@8279011 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8279011

Browse files
author
James Evans
committed
Restored 'draw_idle' method to allow for mpl callbacks to finish processing
before a Qt draw happens.
1 parent 7900ee4 commit 8279011

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,21 @@ def stop_event_loop(self):
416416
stop_event_loop.__doc__ = FigureCanvasBase.stop_event_loop_default.__doc__
417417

418418
def draw_idle(self):
419-
self.update()
419+
# This cannot be a call to 'update', we need a slightly longer
420+
# delay, otherwise mouse releases from zooming, panning, or
421+
# lassoing might not finish processing and will not redraw properly.
422+
# We use the guard flag to prevent infinite calls to 'draw_idle' which
423+
# happens with the 'stale' figure & axes callbacks.
424+
d = self._idle
425+
self._idle = False
426+
427+
def idle_draw(*args):
428+
try:
429+
self.draw()
430+
finally:
431+
self._idle = True
432+
if d:
433+
QtCore.QTimer.singleShot(0, idle_draw)
420434

421435

422436
class MainWindow(QtWidgets.QMainWindow):

0 commit comments

Comments
 (0)
0