Skip to content

Introspection in Fiji Script Editor #84

@ian-coccimiglio

Description

@ian-coccimiglio

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.

Image

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:
Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions