napari / napari-console

A plugin that adds a console to napari
BSD 3-Clause "New" or "Revised" License
3 stars 12 forks source link

Only one console avaliable even with multiple viewer #16

Open Czaki opened 3 years ago

Czaki commented 3 years ago

When open more than one napari viewer in one process only one has an available console. Also viewer variable points to the viewer with the last opened console.

Zrzut ekranu z 2021-08-30 14-10-01

import napari
from skimage import data
from qtpy.QtWidgets import QApplication

app = QApplication([])

viewer1 = napari.view_image(data.astronaut(), rgb=True)
viewer2 = napari.view_image(data.astronaut(), rgb=True)

app.exec_()

I think that this line may produce this problem:

https://github.com/napari/napari-console/blob/fd3a291331e052e591042850b56fd1db5815f784/napari_console/qt_console.py#L106

sofroniewn commented 3 years ago

Yeah this is a known issue, not sure how to fix though! Maybe @Carreau has an idea

Carreau commented 3 years ago

I've seen it, I think there is even another issue for that. Issue IIRC is that the QtConsole makes use of singletons, and is really not made to be displayed twice or more. I'm not sure the time/effort ratio is going to make this a high priority issue.

sofroniewn commented 3 years ago

I've seen it, I think there is even another issue for that.

Yeah it's on main repo, here's at least one https://github.com/napari/napari/issues/1530

Issue IIRC is that the QtConsole makes use of singletons, and is really not made to be displayed twice or more. I'm not sure the time/effort ratio is going to make this a high priority issue.

Agreed - once we figure out the multiviewer / plugin relationship more broadly we can revisit this - maybe we also enforce a singleton but we can deal with that when we get to it

Czaki commented 3 years ago

So the approach of adding variables to the console should be changed to not lost reference to the first viewer.

sofroniewn commented 3 years ago

So the approach of adding variables to the console should be changed to not lost reference to the first viewer.

Yeah we should probably at least address napari/napari#1530