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

Skip to content

Commit d9add67

Browse files
committed
qt: Mark canvas for re-draw after savefig
In some cases, Qt will itself trigger a paint event after closing the file save dialog. When that happens, we need to be sure that the internal canvas is re-drawn. However, if the user is using an automatically-chosen Qt backend but saving with a different backend (such as pgf), we do not want to trigger a full draw in Qt, so just set the flag for next time. Fixes #26272
1 parent 6391678 commit d9add67

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/matplotlib/backends/backend_qtagg.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ def paintEvent(self, event):
7171
finally:
7272
painter.end()
7373

74+
def print_figure(self, *args, **kwargs):
75+
super().print_figure(*args, **kwargs)
76+
# In some cases, Qt will itself trigger a paint event after closing the file
77+
# save dialog. When that happens, we need to be sure that the internal canvas is
78+
# re-drawn. However, if the user is using an automatically-chosen Qt backend but
79+
# saving with a different backend (such as pgf), we do not want to trigger a
80+
# full draw in Qt, so just set the flag for next time.
81+
self._draw_pending = True
82+
7483

7584
@_BackendQT.export
7685
class _BackendQTAgg(_BackendQT):

0 commit comments

Comments
 (0)