forked from fiji/SNT
-
Notifications
You must be signed in to change notification settings - Fork 18
/
ijfinder.py
33 lines (29 loc) · 1.21 KB
/
ijfinder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from os.path import expanduser
from sys import executable, argv
from subprocess import check_output
from PyQt5.QtCore import QDir
from PyQt5.QtWidgets import QFileDialog, QApplication
# The path to your local Fiji.app installation. Here we'll define in a platform
# agnostic way a Fiji.app directory in the desktop of the current user account
local_fiji_dir = os.path.join(expanduser('~'), 'Desktop', 'Fiji.app')
def getpath(directory=expanduser("~")):
# see https://stackoverflow.com/a/46814297
# run this exact file in a separate process, and grab the result
file = check_output([executable, __file__, directory])
return file.strip()
if __name__ == "__main__":
if os.path.isdir(local_fiji_dir):
print(local_fiji_dir)
else:
directory = argv[1]
app = QApplication([directory])
fname = QFileDialog.getExistingDirectory(None,
'Choose the Fiji.app directory of your local '
'Fiji installation subscribed to the NeuroAnatomy '
'Update site', directory)
if fname:
fname = QDir.toNativeSeparators(fname)
print(fname)