Skip to content

Instantly share code, notes, and snippets.

@hanslovsky
Last active December 16, 2019 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanslovsky/54f5533cba68b1a3626aaa3c732ebae1 to your computer and use it in GitHub Desktop.
Save hanslovsky/54f5533cba68b1a3626aaa3c732ebae1 to your computer and use it in GitHub Desktop.
pyimagej-from-qt-thread
import time
def main():
import threading
ij = [None]
def start_qt_and_ij():
from PyQt5 import QtCore, QtWidgets
app = QtWidgets.QApplication([])
app.setQuitOnLastWindowClosed(True)
def start_ij():
import imagej
print(1)
ij[0] = imagej.init('sc.fiji:fiji+net.imagej:imagej-legacy', headless=False)
print(2)
QtCore.QTimer.singleShot(0, start_ij)
app.exec_()
threading.Thread(target=start_qt_and_ij).start()
while ij[0] is None:
time.sleep(0.5)
ij[0].launch()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment