Re: Jython scripting to close a notification or warning window
Posted by
Michael Schmid on
Sep 06, 2019; 7:34pm
URL: http://imagej.273.s1.nabble.com/Jython-scripting-to-close-a-notification-or-warning-window-tp5022417p5022420.html
Hi John,
since ImageJ handles the error condition of having no image by
displaying a notification box, the python try/except does not catch it.
Simply check at the beginning whether at least one image is there, e.g. with
WindowManager.getImageCount()
An alternative is
WindowManager.getCurrentImage()
which returns null if there is no image.
Michael
________________________________________________________________
On 05.09.19 21:46, John wrote:
> I have a jython script which uses TrakEM2 to register a large series of images. If it encounters a situation where it cannot find matching features, it interrupts the script with a notification. I cannot find a way around this.
>
> First, is there a way to run a script with warnings or notifications completely disabled?
>
> Second, is there a way to dismiss them in the script? Here is a more general example:
>
> If I run the following without an image open, the IJ.getImage() will display a “No Image” error notification, after I manually dismiss it, it will move on to the “except”. I cannot find a way to get either the window manager or the “Close All” to dismiss the notification. I’ve shuffled them around and no matter where I put them, I still have to manual close the “No Image” error window.
>
> try:
> imp = IJ.getImage()
>
> IJ.run("Close All") # I've tried this
>
> w = WindowManager # And I've tried this
> win = w.getWindow("No Image")
> win.removeNotify()
> except:
> print "except"
>
> Thanks,
> John
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html