Jython scripts with GenericDialog stopped working

I’m sure I just missed an update or something somewhere (I tried to search but it’s failing me), but I have a number of FIJI Jython scripts that definitely DEFINITELY used to work, I dunno, 2ish years ago, but now when I try to run them the GenericDialog boxes just never pop up, they just proceed into the “STUFF” part of the if/else loop below.

Any clues? Any link to the dumb thing I missed?

from ij import IJ, ImagePlus, ImageStack
from ij.io import DirectoryChooser
from ij.gui import GenericDialog

dc=DirectoryChooser("Choose a folder")
if topfolder is None:
	print "User Canceled"
	gd.addNumericField("Number of channels",4,0)
	gd.addNumericField("Number of cycles",10,0)
if gd.wasCanceled():  
	print "User canceled dialog!"  

Hello Beth,
I think you are missing gd.showDialog() after the last addNumericField to display the dialog before checking what the user clicked.
Strange that it worked in the past like that though, or you sure you did not miss a line when copy pasting the original script ?


Interesting! Some of my older scripts have that gd.showDialog(), at least one doesn’t (the one I copied from, this time, of course, Murphy’s law), I swear that one used to work as well, but it’s old so perhaps I’ve just forgotten.

In any case, thanks, you’re a lifesaver :slight_smile:


since recently you can simplify the input using a single GUI instead of two. Precisely, starting imagej 1.53d you can avoid DirectoryChooser by adding gd.addDirectoryField("Choose a folder", "") to the GenericDialog.

1 Like