Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0870c50

Browse filesBrowse files
committed
Deferred rendering for gui events in Qt5Agg (fixes #4604)
1 parent cefab28 commit 0870c50
Copy full SHA for 0870c50

File tree

Expand file treeCollapse file tree

2 files changed

+5
-15
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-15
lines changed

‎lib/matplotlib/backends/backend_qt5.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5.py
+3-14Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ def resizeEvent(self, event):
334334
hinch = h / dpival
335335
self.figure.set_size_inches(winch, hinch)
336336
FigureCanvasBase.resize_event(self)
337-
self.draw()
338-
self.update()
337+
self.draw_idle()
339338
QtWidgets.QWidget.resizeEvent(self, event)
340339

341340
def sizeHint(self):
@@ -417,17 +416,7 @@ def stop_event_loop(self):
417416
stop_event_loop.__doc__ = FigureCanvasBase.stop_event_loop_default.__doc__
418417

419418
def draw_idle(self):
420-
'update drawing area only if idle'
421-
d = self._idle
422-
self._idle = False
423-
424-
def idle_draw(*args):
425-
try:
426-
self.draw()
427-
finally:
428-
self._idle = True
429-
if d:
430-
QtCore.QTimer.singleShot(0, idle_draw)
419+
self._priv_update()
431420

432421

433422
class MainWindow(QtWidgets.QMainWindow):
@@ -666,7 +655,7 @@ def zoom(self, *args):
666655
self._update_buttons_checked()
667656

668657
def dynamic_update(self):
669-
self.canvas.draw()
658+
self.canvas.draw_idle()
670659

671660
def set_message(self, s):
672661
self.message.emit(s)

‎lib/matplotlib/backends/backend_qt5agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_qt5agg.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,15 @@ class FigureCanvasQTAggBase(object):
6363

6464
def drawRectangle(self, rect):
6565
self._drawRect = rect
66-
self.repaint()
66+
self.draw_idle()
6767

6868
def paintEvent(self, e):
6969
"""
7070
Copy the image from the Agg canvas to the qt.drawable.
7171
In Qt, all drawing should be done inside of here when a widget is
7272
shown onscreen.
7373
"""
74+
FigureCanvasAgg.draw(self)
7475

7576
# FigureCanvasQT.paintEvent(self, e)
7677
if DEBUG:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.