From 2cb8e81431dc86a22db3f1da58e97e1d46528277 Mon Sep 17 00:00:00 2001 From: Alexander Goscinski Date: Sat, 6 Jul 2024 14:45:07 +0200 Subject: [PATCH] Core: Add `no_toolbar` option to CueFigure (#56) The figure widget has toolbar that is now by default disabled in the CueFigure. --- src/scwidgets/cue/_widget_cue_figure.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/scwidgets/cue/_widget_cue_figure.py b/src/scwidgets/cue/_widget_cue_figure.py index 232d04b..97ba4f3 100644 --- a/src/scwidgets/cue/_widget_cue_figure.py +++ b/src/scwidgets/cue/_widget_cue_figure.py @@ -32,6 +32,8 @@ class CueFigure(CueOutput): Specify `traitlets.All` to observe all traits. :param cued: Specifies if it is cued on initialization + :param no_toolbars: + Hide toolbars and headers when using widget mode :param css_syle: - **base**: the css style of the box during initialization - **cue**: the css style that is added when :param @@ -48,6 +50,7 @@ def __init__( None, str, List[str], List[List[str]], Sentinel ] = None, cued: bool = True, + no_toolbars: bool = True, css_style: Optional[dict] = None, **kwargs, ): @@ -77,6 +80,14 @@ def __init__( raise NotImplementedError( f"matplotlib backend " f"{matplotlib.backends.backend!r} not supported." ) + + if no_toolbars: + # hides unnecessary elements shown with %matplotlib widget + self.figure.canvas.header_visible = False + self.figure.canvas.footer_visible = False + self.figure.canvas.toolbar_visible = False + self.figure.canvas.resizable = False + self.draw_display() def clear_display(self, wait=False):