Login  Register

Re: another python scripting question

Posted by Jan Eglinger on Aug 21, 2013; 4:00pm
URL: http://imagej.273.s1.nabble.com/another-python-scripting-question-tp5004517p5004518.html

Dear Aryeh,

On 21.08.2013 4:57 PM, Aryeh Weiss wrote:
> Is it possible to set up a dialog such that any change to the dialog
> will be detected and acted upon, in a python script.

You can start from the following example python script to use a
DialogListener:

from ij.gui import DialogListener, GenericDialog

class MyListener (DialogListener):
        def dialogItemChanged(self, gd, event):
                IJ.log("Something was changed.")

gd = GenericDialog("DialogListener example")
gd.addStringField("Type anything", "change this", 20)
gd.addDialogListener(MyListener())
gd.showDialog()


>
> I want to set up a slider, where whenever I move the slider, something
> will change in an image (like preview).

Starting with the above code, it should be possible to transform Wayne's
nice Java example in the following post into Python/Jython:

http://article.gmane.org/gmane.comp.java.imagej/28353

>
> This is documented in the addPreviewCheckbox method, so what I am asking
> is if this can also be done within python.
> Alternatively, is there a different way to do this?
>

You might also consider using the ExtendedPluginFilter interface, which
provides extended preview functionality.

Hope that helps,
Jan

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