bauerdavid / napari-nD-annotator

BSD 3-Clause "New" or "Revised" License
29 stars 2 forks source link

"Import" and "Export" buttons in Object List widget do not work correctly. #30

Open GenevieveBuckley opened 2 years ago

GenevieveBuckley commented 2 years ago

Describe the bug "Import" and "Export" buttons in Object List widget do not work correctly.

To Reproduce Steps to reproduce the behavior:

  1. Open napari, some example data (cells3d), and the ndannotator plugin "Object List" widget (Plugins > napari-nd-annotator > Object List)
  2. Create some objects and interpolate between the slices
  3. Click the "Export" button in the "Object List" widget
  4. Observe a file dialog widget flash up on the screen very briefly before disappearing. This error is also displayed in the terminal:

Traceback (most recent call last):
  File "/Users/genevieb/mambaforge/envs/test-ndannotator/lib/python3.9/site-packages/napari_nd_annotator/_widgets/object_list.py", line 616, in export_bounding_boxes
    with open(filename, "w") as f:
FileNotFoundError: [Errno 2] No such file or directory: ''

If you suspect this is an IPython 8.4.0 bug, please report it at:
    https://github.com/ipython/ipython/issues
or send an email to the mailing list at ipython-dev@python.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

Expected behavior I expected the file dialog would stay open long enough for me to choose an output filename, and then some output data would be written to disk.

napari info napari: 0.4.15 Platform: macOS-12.3.1-arm64-arm-64bit System: MacOS 12.3.1 Python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:33) [Clang 13.0.1 ] Qt: 5.15.4 PyQt5: 5.15.7 NumPy: 1.23.1 SciPy: 1.9.0 Dask: 2022.8.0 VisPy: 0.9.6

OpenGL:

Screens:

Plugins:

Other packages Not applicable. A new conda environment was created for this bug report, like so

conda create -n test-ndannotator python=3.9 pip ipython
conda activate test-ndannotator
conda install napari
python -m pip install napari-nD-annotator

Additional context Add any other context about the problem here.

bauerdavid commented 2 years ago

I guess this is a problem related to OS, as it works for me on Windows (did not check Linux and MacOS). Would you mind trying this (found here):

from PyQt5.Qt import QApplication, QFileDialog

app = QApplication([])

opts = QFileDialog.Option()
#opts |= QFileDialog.DontUseNativeDialog

fs = QFileDialog.getOpenFileNames(None, "title", "/", "ftext", "", opts)

If this crashes, try uncommenting the opts |= QFileDialog.DontUseNativeDialog line.