ilastik / ilastik-napari

ilastik plugin for napari
MIT License
13 stars 2 forks source link

Plugin broken in recent napari version #1

Closed jni closed 3 years ago

jni commented 3 years ago

It appears we've moved some of the private Qt resources that napari-ilastik was using:

In [2]: import napari_ilastik.plugin
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-6903497af003> in <module>
----> 1 import napari_ilastik.plugin

~/conda/envs/all/lib/python3.8/site-packages/napari_ilastik/plugin.py in <module>
      4 import sparse
      5 from napari import Viewer
----> 6 from napari._qt.containers.layers import QtLayerList
      7 from napari.layers import Image, Labels, Layer
      8 from napari.qt.threading import thread_worker

ModuleNotFoundError: No module named 'napari._qt.containers.layers'

Not sure what the best fix is but thought I'd note it down.

sofroniewn commented 3 years ago

I think it might now just be from napari._qt.containers import QtLayerList, see https://github.com/napari/napari/blob/700300bc7d62489bd52050c30c647c4506f4f6bc/napari/_qt/containers/qt_layer_list.py#L35

jni commented 3 years ago

Ideally we should have a discussion about why you're using a private API and whether we could provide some public functionality to suit your needs, though! 😊

emilmelnikov commented 3 years ago

Hi @sofroniewn and @jni! Sorry for not fixing this earlier. It was left as-is from the demo day.

I need QtLayerList for displaying and selecting layers in several Qt combo boxes, see https://github.com/napari/napari/pull/2493#discussion_r608473885.

Judging by the underscored name, napari._qt.containers is a private module, but I think this QtLayerList or something similar will be useful for other people as well. It would be great to have this provided as a public API.

jni commented 3 years ago

@emilmelnikov we can alias Qt things that we want to be public in napari.qt, but my question is why you want this instead of the base viewer.layers model (the type is napari.components.layerlist.LayerList)?

emilmelnikov commented 3 years ago

@emilmelnikov we can alias Qt things that we want to be public in napari.qt, but my question is why you want this instead of the base viewer.layers model (the type is napari.components.layerlist.LayerList)?

I needed one of QAbstractItemModel to plug into Qt widgets. As far as I understand, LayerList mimics Python list, which is awesome to use from Python, but, unfortunately, you cannot use it as a data source in Qt views.

sofroniewn commented 3 years ago

I guess this is something that we could also think about pulling out into supeqt - see https://github.com/napari/superqt/issues/6 but it runs into the same questions about our own event system @tlambert03

tlambert03 commented 3 years ago

it runs into the same questions about our own event system @tlambert03

well, this is kind of what got me started on making psygnal 😄 I do want to make those QtViews more public. i think they're nice objects... and I know @alisterburt wanted them too. So, maybe?