Get the results of the dialog

Background

Hello,
I want to get the string or boolean from the dialog.

from ij import IJ
from ij.gui import GenericDialog
from fiji.util.gui import GenericDialogPlus


num = 2

if num == 1:
	print("hi")
else:
	gdp = GenericDialogPlus("test")
	gdp.addChoice("Are you sure to analyze?",["YES","NO"],"NO")
	gdp.showDialog()
	AAA = gdp.getChoices()
	print(str(AAA))

#> [java.awt.Choice[choice14,164,47,51x22,invalid,current=NO]]

I would like to get a simple result, but I can’t get it. (e.g. “YES”, “NO” or “True or False”).
Is there any way to get result with out using regex?.

I’m using “GenericDialogPlus” because I want to include dialogs in my if statements, but I would like to use this if possible.

Apologies in advance if this is covered elsewhere, can’t find it easily. Thanks,

1 Like

Hi Dan @11137 ,

I think you are searching for gdp.getNextChoice()

You can explore possibilities a bit more easilty from Integrated Development Environments such as IntellIJ or Eclipse as they come with great auto-completion:
image

You can read a bit more about combining jython scripts and IDEs in this blog post.

Let us know if this helps!

Cheers,
Robert

1 Like

I’ve been developing in VSCODE, which is not very convenient and frustrating.
I will try to get it installed.

Big Thanks
Dan

1 Like