how to end a jython script ?

Posted by Leon Espinosa-3 on
URL: http://imagej.273.s1.nabble.com/how-to-end-a-jython-script-tp5009398.html

Hello, I wonder if there is a method to finish a Jython script. What I have in mind is something like :


import sys
from ij.gui import NonBlockingGenericDialog

gd0=NonBlockingGenericDialog("Test")
gd0.showDialog()

if gd0.wasCanceled():
        print "Canceled"
        #sys.exit("end") This works if the script is running in the script editor but it kills Fiji if it is installed in the plugins directory like "Test_exit.py"

if gd0.wasOKed():
        print "OK"
        # do the rest of the script



Of course I could do :

if gd0.wasOKed():
        print "OK"
        # do the rest of the script

else : print "end"


But after some Dilalog windows I will have lot of nested "if... else" blocks.


thank you for any help !

All the best, Leon

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html