Is it possible to open the Napari viewer with the layer controls and layer list GUI elements hidden?

Hi everyone,

I would like to open the Napari viewer with the layer controls and layer list GUI elements hidden, is this possible?. In addition, I was trying to check what are the key binding to enable/dissable the layer controls and layer list GUI elements, but when I click on the Help menubar option -> Show key binding nothing happens, I have opened an issue to report this bug (Show Key Bindings menu option is not working in Napari 0.4.3 · Issue #2128 · napari/napari · GitHub).

By exploring the menubar, I can enable/dissable the layer controls and layer list GUI elements by clicking on the Window menubar option->layer controls (as well as clicking on the Window menubar option->layer list), but I would like to do this using key bindings :slightly_smiling_face:, as well as having the option to open the Napari viewer showing only the canvas with the layer controls and layer list GUI elements hidden.

Thank you very much for your help :wink:

Hello, you can access the Qt widgets using the viewer instance and set them to be not visible as follows:

import napari

with napari.gui_qt():
    viewer = napari.Viewer()
    viewer.window.qt_viewer.dockLayerList.setVisible(False)
    viewer.window.qt_viewer.dockLayerControls.setVisible(False)

You can also install your own key bindings as described here.

import napari

with napari.gui_qt():
    viewer = napari.Viewer()

    @viewer.bind_key('l')
    def toggle_dock_layer_list(viewer: napari.Viewer):
        dock_layer_list = viewer.window.qt_viewer.dockLayerList
        list_visible = dock_layer_list.isVisible()
        dock_layer_list.setVisible(not list_visible)


    @viewer.bind_key('c')
    def toggle_dock_layer_controls(viewer: napari.Viewer):
        dock_layer_controls = viewer.window.qt_viewer.dockLayerControls
        controls_visible = dock_layer_controls.isVisible()
        dock_layer_controls.setVisible(not controls_visible)

1 Like