imagej / pyimagej

Use ImageJ from Python
https://pyimagej.readthedocs.io/
Other
462 stars 81 forks source link

pyimagej interefering with Tkinter GUI on Mac #39

Open jluethi opened 5 years ago

jluethi commented 5 years ago

I have an application using pyimagej for image processing and want to make a very simple interface for the users to provide some inputs. I am using tkinter for this gui. When I initialize pyimagej either in that script or one of its imports, it fails to produce the gui, but does not crash. It just shows the following message: 2019-05-31 16:47:01.581 python[27137:9099880] In -[NSApplication(NSQuietSafeQuit) _updateCanQuitQuietlyAndSafely], _LSSetApplicationInformationItem(NSCanQuitQuietlyAndSafely) returned error -50

Here is some dummy example code that reproduces this:

import imagej
import tkinter as tk
ij = imagej.init('sc.fiji:fiji:2.0.0-pre-10')
root = tk.Tk()
tk.Label(root, text='Test1').grid(row=0, column=0)
tk.Checkbutton(root, text='Test2').grid(row=1, column=0)
root.mainloop()

Without the imagej initialization, it runs fine. It happens both with a maven initialization and when wrapping the local Fiji installation. This problem does not reproduce on Windows for me (there, the gui comes up as expected) and I don't know whether it reproduces on Linux. I do get this issue on my Mac running macOS 10.14.5.

ctrueden commented 5 years ago

I am guessing this is related to Python GUI support on macOS. Might be related to macOS threading and the Cocoa event loop (see also #23)?

Things to try:

  1. You could try running with a framework build of Python i.e. pythonw instead of python.
  2. You could try using this approach to launch your script and see if it makes any difference.
jluethi commented 5 years ago

Thanks @ctrueden ! This currently isn't a priority for me, as our production runs on Windows. Just wanted to document the issue for the moment. If I get to check this out later, I'll report back. Thank you!