Commit 549dd326 authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch '94-notebook-backend' into 'dev'

Resolve "FEATURE: add possibility to print into a notebook"

Closes #94

See merge request !66
parents c2cac0a6 58728070
Pipeline #604 passed with stage
in 12 minutes and 20 seconds
......@@ -449,6 +449,16 @@ class MplFig():
"""
pass
# PRINT IN NOTEBOOK ------------------------------------------------
def print_in_notebook(self, **kwargs):
"""Print the rendered figure into the current notebook.
In the server context the MplFig can not be rendered, and therefore,
can not print anything into the notebook.
"""
pass
# PRINT TO FILE ----------------------------------------------------
def print_to_file(self, filename, *args, **kwargs):
"""Print the rendered figure into a file.
......@@ -725,6 +735,24 @@ class MplFig():
self._initialize(*args, **kwargs)
self.plot()
# PRINT IN NOTEBOOK --------------------------------------------------
def _print_in_notebook_local(self, **kwargs):
"""Print the rendered figure into the current notebook.
keywords:
- as_seen : [without recalling the MplFig.plot method]
"""
as_seen = kwargs.get('as_seen', False)
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
canvas = FigureCanvas(self) # set the figures canvas /!\ this will destroy the bounding to a window.
self.bounded_to_win = False
return(self)
# PRINT 2 FILE -------------------------------------------------------
def _print_to_file_local(self, filename, *args, **kwargs):
"""Print the rendered figure into a file.
......@@ -881,6 +909,7 @@ class MplFig():
_plot_client = _plot_local
_reset_client = _reset_local
_print_to_file_client = _print_to_file_local
_print_in_notebook_client = _print_in_notebook_local
def _de_sync_fig_client(self):
if self.client is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment