Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ImageJ GUI work on macOS #23

Open
ctrueden opened this issue Jan 7, 2019 · 2 comments
Open

Make ImageJ GUI work on macOS #23

ctrueden opened this issue Jan 7, 2019 · 2 comments
Labels
Milestone

Comments

@ctrueden
Copy link
Member

@ctrueden ctrueden commented Jan 7, 2019

When launching ImageJ with a display from Python on macOS, it hangs. See 68dad62 for the current workaround and links to more information. The pyimagej code should try to be clever and start the Cocoa event loop itself before spinning up Java.

See also
https://github.com/imglib/imglyb/blob/1ff6fd12ae5270093be6f3ce340247bde1a45dfc/imglyb/OSXAWTwrapper.py

@oeway

This comment has been minimized.

Copy link

@oeway oeway commented Oct 26, 2019

Same issue here, the script hangs when headless=False. I get the GUI by following the suggestions in #39, but without the FIJI menu (instead, it shows only a single menu item named python).

  1. run conda active pyimagej
  2. run pip install pyobjc
  3. download OSXAWTwrapper.py
  4. write a test script named startPyImageJGUI.py with the following content:
import time
import imagej

ij = imagej.init('/Applications/Fiji.app', headless=False)
ij.ui().showUI()

while True:
    time.sleep(1)
  1. run python OSXAWTwrapper.py startImageJ.py and I got GUI work:

Screen Shot 2019-10-26 at 8 05 07 PM

However, the fiji menu didn't show as expected, any idea? @ctrueden

@ctrueden

This comment has been minimized.

Copy link
Member Author

@ctrueden ctrueden commented Oct 30, 2019

@oeway Hmm. I guess that since Java is started inside the Python process, the usual macOS menu bar logic does not work?

I don't immediately know how to fix it. But one quick workaround is to use:

ij = imagej.init('/Applications/Fiji.app', headless=False)
ij.ui().showUI("swing")

This will pop up the Swing UI instead of the legacy ImageJ1 UI. In my quick experimentation, major things including legacy IJ1 plugins do still work—although you may encounter rough edges in some cases.

Relatedly: I am exploring integrating the OSXAWTWrapper logic directly into pyimagej so that you don't have to do so many extra steps manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.