Viewer buttons don't work as expected when having two napari viewers in a single program
See original GitHub issueš Bug
Hi,
Since napari 0.4.8, the buttons that by default are in the lower left corner donāt work as expected when having two napari viewers in a single program. More specifically, when clicking one of the lower left corner buttons in the napari viewer that was added first, the buttonās action is executed on the other viewer. This seems to be related to the new action manager features that were added in 0.4.8.
Iām not sure if this is actually a bug or if napari simply isnāt meant to be used like this, but until 0.4.8 I hadnāt experienced any issues, so it would be nice if it could continue to work when used like this.
To Reproduce
Steps to reproduce the behavior:
- Run the following minimal working example with napari 0.4.8 or later:
import napari
from qtpy import QtWidgets
from skimage import data
class Window(QtWidgets.QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.napari1 = napari.Viewer(show=False)
self.napari1.add_image(data.cat())
self.napari2 = napari.Viewer(show=False)
self.napari2.add_image(data.astronaut())
self.setLayout(QtWidgets.QHBoxLayout())
self.layout().addWidget(self.napari1.window._qt_window)
self.layout().addWidget(self.napari2.window._qt_window)
app = QtWidgets.QApplication([])
window = Window()
window.show()
app.exec_()
- Click the console button in the lower left corner of the napari viewer that displays the cat image.
The console will show up in the napari viewer displaying the astronaut image, instead of in the one displaying the cat image.
The same issue applies to the other buttons in the lower left corner.
Environment
napari: 0.4.9
Platform: Windows-10-10.0.19041-SP0
Python: 3.9.4 (default, Apr 9 2021, 11:43:21) [MSC v.1916 64 bit (AMD64)]
Qt: 5.15.2
PyQt5: 5.15.4
NumPy: 1.19.3
SciPy: 1.6.3
Dask: 2021.05.0
VisPy: 0.6.6
OpenGL:
- GL version: 4.6.0 NVIDIA 465.89
- MAX_TEXTURE_SIZE: 32768
Screens:
- screen 1: resolution 2560x1440, scale 1.0
Plugins:
- console: 0.0.3
- scikit-image: 0.4.9
- svg: 0.1.5
Additional context
The keyboard shortcuts for the buttons work as expected.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
definitely a bug! we still support multiple independent viewer instances. Thanks for the very clear report!
git bisect
says this started on #2612.