Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnnsrs committed Oct 25, 2023
1 parent 806b9d1 commit d2a93aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions mikroj/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, *args, auto_init=None, **kwargs) -> None:
auto_init if auto_init else self.settings.value("auto_initialize", True)
)
self.plugins_dir = self.settings.value("plugins_dir", "")

self._ij = None
self.bridge = ImageJBridge()
self.transpile_registry = TranspileRegistry()

Expand Down Expand Up @@ -147,6 +147,11 @@ def __init__(self, *args, auto_init=None, **kwargs) -> None:
self.initialize()

def request_imagej_dir(self):
if self._ij:
self.magic_bar.magicb.setDisabled(True)
self._ij.ui().dispose()
del self._ij
self._ij = None
dir = QtWidgets.QFileDialog.getExistingDirectory(
parent=self, caption="Select ImageJ directory"
)
Expand All @@ -157,6 +162,9 @@ def request_imagej_dir(self):
self.image_j_path = ""
self.settings.setValue("image_j_path", "")

if self.image_j_path != "":
self.initialize()

def open_settings(self):
self.request_imagej_dir()
pass
Expand Down Expand Up @@ -396,14 +404,14 @@ def initialize(self):
) # This is a hack until https://github.com/imagej/pyimagej/issues/150
self._ij = imagej.init(self.image_j_path, mode="interactive")
os.chdir(path) ##
self.imagej_button.setText("ImageJ Initialized")
self.magic_bar.magicb.setDisabled(False)

self.vlayout.update()

self.bridge.set_ij_instance(self._ij)
self._ij.ui().showUI()
self.magic_bar.magicb.setDisabled(False)
self.imagej_button.setText("ImageJ Initialized")

except Exception as e:
self.image_j_path = None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ packages = [{ include = "mikroj" }]
python = "<3.12,>=3.8"
pyimagej = "1.4.0"
scyjava = "^1.6.0"
arkitekt = { version = ">=0.5.52", extras = [
arkitekt = { version = ">=0.5.56", extras = [
"reaktion",
"rekuest",
"mikro",
Expand Down

0 comments on commit d2a93aa

Please sign in to comment.