Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: destroy figs in python when destroyed in js
- only actually closes the figure (in the mpl sense) if all of the managers active comms are dead - closes figure when all visible copies are removed from dom - eliminates many of the [IPKernelApp] ERROR | No such comm: XXXX errors closes #4841
- Loading branch information
Showing
2 changed files
with
38 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,15 +55,21 @@ mpl.mpl_figure_comm = function(comm, msg) { | |
}; | ||
|
||
mpl.figure.prototype.handle_close = function(fig, msg) { | ||
fig.root.unbind('remove') | ||
|
||
// Update the output cell to use the data from the current canvas. | ||
fig.push_to_output(); | ||
var dataURL = fig.canvas.toDataURL(); | ||
// Re-enable the keyboard manager in IPython - without this line, in FF, | ||
// the notebook keyboard shortcuts fail. | ||
IPython.keyboard_manager.enable() | ||
$(fig.parent_element).html('<img src="' + dataURL + '">'); | ||
fig.send_message('closing', {}); | ||
fig.ws.close() | ||
fig.close_ws(fig, msg); | ||
} | ||
|
||
mpl.figure.prototype.close_ws = function(fig, msg){ | ||
fig.send_message('closing', msg); | ||
// fig.ws.close() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tacaswell
Author
Member
|
||
} | ||
|
||
mpl.figure.prototype.push_to_output = function(remove_interactive) { | ||
|
@@ -126,6 +132,12 @@ mpl.figure.prototype._init_toolbar = function() { | |
titlebar.prepend(buttongrp); | ||
} | ||
|
||
mpl.figure.prototype._root_extra_style = function(el){ | ||
var fig = this | ||
el.on("remove", function(){ | ||
fig.close_ws(fig, {}); | ||
}); | ||
} | ||
|
||
mpl.figure.prototype._canvas_extra_style = function(el){ | ||
// this is important to make the div 'focusable | ||
|
?