Skip to content

Commit

Permalink
Update README and introduce NAPARI_JL_USE_CONDA environmental variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mkitti committed Mar 8, 2021
1 parent 2a9a642 commit ba7a837
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ This package is currently not in the Julia registry. To install, add it directly

```julia
using Pkg
Pkg.add("https://github.com/mkitti/Napari.jl.git")
using Napari
Napari.install_with_pip() # If you have not installed Napari yet
Pkg.add("Napari")
# Alternatively, use the following to get the development version
# Pkg.add("https://github.com/mkitti/Napari.jl.git")
using Napari # Will use pyimport_conda("Napari") unless parse(Bool, ENV["NAPARI_JL_USE_CONDA"]) == false
```

## Quick Start
Expand Down Expand Up @@ -120,6 +121,10 @@ For other Julia types, you can overload these methods by importing the appropria
import Napari: view_image, add_image
```

## Compatability with Napari

This package has been tested against Napari release versions 0.3.9 and 0.4.6.

## Advanced

This package defaults to using pyqt5 and uses `PyCall.pygui_start(:qt5)` to initialize the the QT event loop.
Expand All @@ -132,4 +137,4 @@ It is based around an earlier script, `napari.jl`, by Mark Kittisopikul that was

## License

This package is licensed under the [3-Clause "Revised" BSD License](https://github.com/mkitti/Napari.jl/blob/main/LICENSE).
This package is licensed under the [3-Clause "Revised" BSD License](https://github.com/mkitti/Napari.jl/blob/main/LICENSE).
20 changes: 12 additions & 8 deletions src/Napari.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@ include("layer_name_macros.jl")
include("viewer.jl")
include("install.jl")

function __init__(qt = parse(Bool, get( ENV, "NAPARI_JL_QT", "true") ) )
function __init__(;
use_qt = parse(Bool, get( ENV, "NAPARI_JL_QT", "true") ),
use_conda = parse(Bool, get(ENV, "NAPARI_JL_USE_CONDA", "true") )
)
try
# We need to coordinate between PyCall and Napari
# https://github.com/JuliaPy/PyCall.jl/blob/master/src/gui.jl#L140
# https://github.com/napari/napari/blob/master/napari/_qt/event_loop.py

#napari = pyimport("napari")
napari_local = pyimport_conda("napari", "napari", "conda-forge")
if use_conda
napari_local = pyimport_conda("napari", "napari", "conda-forge")
else
napari_local = pyimport("napari")
end
copy!(napari,napari_local)

@info "napari version" version = napari.__version__
@info dirname(napari.__file__)
if qt
if use_qt
pygui_start(:qt5)
# Needed to kickstart Qt5 for some reason
QApplication = pyimport("qtpy.QtWidgets").QApplication
Expand All @@ -59,7 +65,7 @@ function __init__(qt = parse(Bool, get( ENV, "NAPARI_JL_QT", "true") ) )
else
@warn """pygui_start(:qt5) not run. Start the event loop manually.
You may need to initailize qtpy.QtWidgets.QApplication.
See environmental variable NAPARI_JL_NOQT"""
See environmental variable NAPARI_JL_QT"""
end
catch err
@warn """Napari.jl has failed to import qtpy and napari from Python.
Expand Down Expand Up @@ -100,6 +106,4 @@ function astronaut()
pyimport("skimage.data").astronaut()
end



end
end

0 comments on commit ba7a837

Please sign in to comment.