Login  Register

Re: another python scripting question

Posted by Aryeh Weiss on Aug 21, 2013; 6:58pm
URL: http://imagej.273.s1.nabble.com/another-python-scripting-question-tp5004517p5004522.html

Dear Jan,

Thank you for your quick response. I sent this just before I left work,
and when I got home, your response was already here.

On 8/21/13 7:00 PM, Jan Eglinger wrote:

> 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()
>
>

This is great -- works as advertised. I have couple of questions which I
could not figure out.

1. I would really like for the action to occur only after I finish
moving the slider. This is because I will be subtracting two images, and
this takes some time. Is there an event (either dialog or mouse) that I
can test for this?

2. Where can I find a complete list of dialog events? I searched around,
but when I did not find it, I tried just printing the event argument, to
see what events are being passed. I found:
TEXT_VALUE_CHANGED when moved the sliders
ITEM_STATE_CHANGED  when I checked or unchecked a checkbox

I tried radio buttons (with the idea that I will push a button to run
the calculation), but they did not produce any event and did not invoke
the listener.

I can use the  checkbox to do what I want, but I assume there is a
better way.

(Maybe a mouse listener in the dialog window?)


>>
>> 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.
>


Is there an example of this in python?

Best regards
--aryeh
--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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