Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FutureWarning for accessing napari qt_viewer #189

Open
jacopoabramo opened this issue Oct 14, 2023 · 8 comments
Open

FutureWarning for accessing napari qt_viewer #189

jacopoabramo opened this issue Oct 14, 2023 · 8 comments

Comments

@jacopoabramo
Copy link
Collaborator

Since napari 0.5.0 is approaching release, I think we should focus on the following warning:

FutureWarning: Public access to Window.qt_viewer is deprecated and will be removed in
v0.5.0. It is considered an "implementation detail" of the napari
application, not part of the napari viewer model. If your use case
requires access to qt_viewer, please open an issue to discuss.

From the stack trace I see that these warnings are caused by the following code in the NapariBaseWidget class:

        # Move layer list to bottom
        napariViewer.window._qt_window.removeDockWidget(
            napariViewer.window.qt_viewer.dockLayerList
        )
        napariViewer.window._qt_window.addDockWidget(
            napariViewer.window.qt_viewer.dockLayerList.qt_area,
            napariViewer.window.qt_viewer.dockLayerList
        )

@kasasxav do you know what does this do? Is it necessary or can we remove it?

@jacopoabramo
Copy link
Collaborator Author

Currently the napari layer list looks like this:

image

While ImSwitch napari looks like this:

image

To me they look ratherly similar. Or am I missing something?

@jacopoabramo
Copy link
Collaborator Author

I see that this is used as a way to add custom napari widgets to the interface anyway...

@beniroquai
Copy link
Collaborator

Should we do anything about it?

@kasasxav
Copy link
Collaborator

Heyy hope all is good guys :)

I would say try to add an issue to their repo and ask for an alternative way, I used something similar to add available napari plugins to ImSwitch and the code was something they suggested. So probably they have better alternatives now.

@jacopoabramo
Copy link
Collaborator Author

@kasasxav will do that, thanks!

@kasasxav
Copy link
Collaborator

Sorry forgot to say what it does,
NapariBaseWidget is a general class for dealing with Napari within ImSwitch.

There are some widgets that are subclass of NapariBaseWidget, like the shift buttons or the Reset for update levels (

self.NapariResetViewWidget = naparitools.NapariResetViewWidget.addToViewer(self.napariViewer, 'right')
) . The shift buttons are the arrows in the GUI that can align one image to another. In this case, the add and remove dock functions deal with adding a widget inside the napari GUI.

Also, there is a subclass of NapariBaseWidget called NapariHybridWidget, that is used as a superclass for those widgets that want to add stuff into the viewer like the ULensesWidget that adds a layer of an array of dots superimposed to the image. But they don't use specifically the functions addDockWidget and removeDockWidget

@jacopoabramo
Copy link
Collaborator Author

Awesome, thanks Xavier. I'll report this to the napari devs and see what comes out of it

@Czaki
Copy link

Czaki commented Oct 17, 2023

qt_vierer deprecation is postponed to 0.6.0 napari/napari#6283
You still may depend on Viewer.window._qt_viewer if you do not plan to support different backends in the future, but then I suggest setup testing against the main branch of the napari repository https://github.com/4DNucleome/PartSeg/blob/develop/.github/workflows/test_napari_repo.yml

As you see, you are a standalone application, not a plugin.
Also, QtViewer itself is available in napari.qt module as part of public API.

So instead of using Viever, you may use QtViewer and ViewerModel.
You need then create own main window, but you will have full control over its design. You may see https://github.com/4DNucleome/PartSeg as an example of an application that provides its own GUI but uses QtViewer for rendering data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants