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 78aa7a5

Browse filesBrowse files
committed
FIX : first pass at fixing nbagg close issue
Add callback to destroy figure when the user hits the red x in the notebook. This is not the correct solution, but it (might) work for now.
1 parent 60eace2 commit 78aa7a5
Copy full SHA for 78aa7a5

File tree

Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-0
lines changed

‎lib/matplotlib/backends/backend_nbagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_nbagg.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,16 @@ def new_figure_manager_given_figure(num, figure):
223223
"""
224224
Create a new figure manager instance for the given figure.
225225
"""
226+
from _pylab_helpers import Gcf
227+
228+
def closer(event):
229+
Gcf.destroy(num)
230+
226231
canvas = FigureCanvasNbAgg(figure)
227232
if rcParams['nbagg.transparent']:
228233
figure.patch.set_alpha(0)
229234
manager = FigureManagerNbAgg(canvas, num)
235+
canvas.mpl_register('close_event', closer)
230236
return manager
231237

232238

‎lib/matplotlib/backends/backend_webagg_core.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_webagg_core.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ def handle_event(self, event):
329329
self.send_event('figure_label', label=figure_label)
330330
self._force_full = True
331331
self.draw_idle()
332+
elif e_type == 'closing':
333+
self.close_event()
334+
332335
else:
333336
handler = getattr(self, 'handle_{0}'.format(e_type), None)
334337
if handler is None:

0 commit comments

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