Skip to content

Commit 2cb8e81

Browse files
authored
Core: Add no_toolbar option to CueFigure (#56)
The figure widget has toolbar that is now by default disabled in the CueFigure.
1 parent e480910 commit 2cb8e81

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/scwidgets/cue/_widget_cue_figure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class CueFigure(CueOutput):
3232
Specify `traitlets.All` to observe all traits.
3333
:param cued:
3434
Specifies if it is cued on initialization
35+
:param no_toolbars:
36+
Hide toolbars and headers when using widget mode
3537
:param css_syle:
3638
- **base**: the css style of the box during initialization
3739
- **cue**: the css style that is added when :param
@@ -48,6 +50,7 @@ def __init__(
4850
None, str, List[str], List[List[str]], Sentinel
4951
] = None,
5052
cued: bool = True,
53+
no_toolbars: bool = True,
5154
css_style: Optional[dict] = None,
5255
**kwargs,
5356
):
@@ -77,6 +80,14 @@ def __init__(
7780
raise NotImplementedError(
7881
f"matplotlib backend " f"{matplotlib.backends.backend!r} not supported."
7982
)
83+
84+
if no_toolbars:
85+
# hides unnecessary elements shown with %matplotlib widget
86+
self.figure.canvas.header_visible = False
87+
self.figure.canvas.footer_visible = False
88+
self.figure.canvas.toolbar_visible = False
89+
self.figure.canvas.resizable = False
90+
8091
self.draw_display()
8192

8293
def clear_display(self, wait=False):

0 commit comments

Comments
 (0)