def display(segments: Iterable[Segment], text: str) -> None: """Render segments to Jupyter.""" from IPython.display import display as ipython_display html = _render_segments(segments) jupyter_renderable = JupyterRenderable(html, text) ipython_display(jupyter_renderable)
def imgcat(self, line=''): '''%imgcat magic, equivalent to imgcat(<expression>). Usage: %imgcat <expression> ''' if not line: ipython_display(Markdown("Usage: `%imgcat [python code]`")) return if os.path.isfile(line): with open(line, mode='rb') as fp: ret = fp.read() else: global_ns = self.shell.user_global_ns local_ns = self.shell.user_ns ret = eval(line, global_ns, local_ns) # pylint: disable=eval-used if IS_NOTEBOOK: from .imgcat import to_content_buf buf = io.BytesIO(to_content_buf(ret)) im = PIL.Image.open(buf) ipython_display(im) buf.close() else: from .imgcat import imgcat imgcat(ret)
def display(value): if inside_ipython(): from IPython.display import display as ipython_display, HTML if isinstance(value, str): ipython_display(HTML(rst_to_html(value))) else: ipython_display(value) else: print(value)
def display(widget): """ Open up a new browser window and display widget in a jupyter notebook output cell :param widget: the widget to display :return: """ _check_started() jupyter_singleton.singleton_app.open_singleton() ipython_display(widget)
def display(segments: Iterable[Segment], text: str) -> None: """Render segments to Jupyter.""" html = _render_segments(segments) jupyter_renderable = JupyterRenderable(html, text) try: from IPython.display import display as ipython_display ipython_display(jupyter_renderable) except ModuleNotFoundError: # Handle the case where the Console has force_jupyter=True, # but IPython is not installed. pass
def __enter__(self): self.reset() if self._displays is None: self._displays = [ ipython_display(self, display_id=True) if _in_zmq_interactive_shell() else FileDisplay(self._position)] return self
def notebook(self): """ Display SVG in Jupyther notebook. """ try: # Import IPython display for notebook from IPython.display import SVG as ipython_display # Display in notebook return ipython_display(self.string) except ImportError: raise Warning(""" IPython not installed. """)
def display(*args, **kwargs): if in_ipynb(): try: from IPython.display import display as ipython_display return ipython_display(*args, **kwargs) except: warnings.warn("ERROR loading display from IPython") pass
def _create_display(obj: object, position: Tuple[int, int]): """Create an updateable display object. Args: obj: Initial object to display. position: Tuple specifying position of display within a sequence of displays with first entry corresponding to the zero-indexed position and the second entry the total number of displays. Returns: Object with `update` method to update displayed content. """ if _in_zmq_interactive_shell(): return ipython_display(obj, display_id=True) else: return FileDisplay(position)
def show_image(self, image, **options): ipython_display(image) return 1
def run(constructor): """Run the given IDOM elemen definition as a Jupyter Widget. This function is meant to be similarly to ``idom.run``. """ return ipython_display(LayoutWidget(constructor()))
def selective_plot(self, what: Any): that = what() if callable(what) else what if isinstance(that, bokeh.plotting.Figure): bokeh.plotting.show(that) else: ipython_display(that)
def display(self): ipython_display(self) return self
def display(text): ipython_display(HTML(text))