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

Add an ij.py.show_ui function #260

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/imagej/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,26 @@ def show(self, image, cmap=None):
pyplot.imshow(self.from_java(image), interpolation="nearest", cmap=cmap)
pyplot.show()

def show_ui(self, name: str = None) -> None:
"""Display the ImageJ2 user interface.

:param name: The name of the ImageJ2 UI to show, or None for the
default interface, which is "legacy" (the original ImageJ
UI) when the add_legacy initialization flag is set, and
"swing" (the "pure ImageJ2" UI) otherwise.
"""

ij = self._ij

def show_or_raise_ui():
ui = ij.ui().getDefaultUI() if name is None else ij.ui().getUI(name)
if ui.isVisible():
ui.getApplicationFrame().setVisible(True)
else:
ui.show()

ij.thread().queue(show_or_raise_ui)

def sync_image(self, imp: "jc.ImagePlus" = None):
"""Synchronize data between ImageJ and ImageJ2.

Expand Down