Dock widgets without close button
See original GitHub issue🚀 Feature
It would be cool to have dock widgets which don’t have a close-button.
Motivation
I’m having issues with workflows in napari where the user closed dock widgets after configuring them. If the user would only hide the dock widget, everything would be cool.
Pitch
The Dockwidget class used in napari has a constructor parameter close_btn
which would allow to have dock widgets without a close button (see)
However, this parameters is not available when calling viewer.window.add_dock_widget(...)
. It would be practical if the parameter was also available in the API (e.g. here).
Alternatives
At the moment, I’m doing it like this (see):
dw = viewer.window.add_dock_widget(...)
dw._close_btn = False
And it works fine. It would be cool though if this was possible without accessing private class members.
Additional context
Btw. I tried to hide the close button by changing the features
of the DockWidget as described in the QT documentation. This didn’t work, as napapri is using a custom header with custom buttons. It might make sense to mention in the documentation (e.g. of setFeatures) that the functionality described here doesn’t work in napari: https://doc.qt.io/qt-5/qdockwidget.html#DockWidgetFeature-enum
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
Maybe I wasn’t clear, i like hiding! Open, manipulate, hide to get more viewer space, restore … (restore works for plugins, but not widgets in my experience) I just think I should have the option to close, to kill a widget/plugin… I guess in your case there’s an extra issue beyond the UI/UX aspect (close vs hide)…
Here is another case where closing messes up things:
dock_widget = viewer.window.add_dock_widget(module_widget, name="My Widget", menu=viewer.window.window_menu)
window
menu.This is expected as close removes the widget completely from memory. It is just not something that I want from a design perspective.
solution as stated in the forum.image.sc: use
dock_widget._close_btn=False