-
Notifications
You must be signed in to change notification settings - Fork 15
Description
I got around to testing introspection in scyjava, and it overall works quite nicely!
However, when using the (Python3-enabled) Fiji's Script Editor, the reflection functions print to the calling terminal, rather than the Fiji script editor (see screenshot below). I suspect this behavior arises because all of the scyjava modules (like src() below) are imported prior to Fiji being initialized (i.e., in the /config/fiji.py script). At this time, stdout refers to the calling terminal, not the ScriptContextWriter. Because Python doesn't dynamically update imports, attempting to import the libraries again doesn't override _stdout.write to point to the script editor.
A bad workaround is to append this to the beginning of the script:
#@ ImageJ ij
import importlib
import scyjava.inspect
from scyjava.inspect import methods, src
importlib.reload(scyjava.inspect)
src(ij)Which then produces the ideal result:

However, I'm not sure what the best method to accomplish this is. Maybe it'd be to somehow edit the config script to specify which writer to use. Ideally there's something simpler.
