question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
psobolewskiPhDcommented, Apr 2, 2022

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)…

0reactions
MosGeocommented, Aug 21, 2022

Here is another case where closing messes up things:

  1. Add dock_widget using dock_widget = viewer.window.add_dock_widget(module_widget, name="My Widget", menu=viewer.window.window_menu)
  2. Run napari. Widget is visible and its menu action is there in the window menu.
  3. Close widget.
  4. Menu action is gone 😔

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I remove the 'close' icon when I create a dock widget in ...
When I add my dock widget with add_dock_widget() is there a way to specify no close button with something like close_btn=False .
Read more >
how can i set QDockWidget without close button? - Qt Forum
hello everyone, i use the QDockWidget widget, but i do not want user to close the QDockWidget, so ,i want to hidden the...
Read more >
How to hide Close Button "X" on Widget ? - Qt Centre Forum
Hi all Working on Qt4.3.4 on Windows XP, I want to know how to hide Close (X) that is appearing on right hand...
Read more >
Qt: how to add a close and minimize button to a widget, that is ...
I want to embed some widgets into anothe Qt widget (into docking widget, for example). But I want to let user minimize or...
Read more >
Change Desktop & Dock settings on Mac - Apple Support (AZ)
Minimize an app window to the app icon in the Dock. If the option isn't turned on, the window is minimized to an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found