Login  Register

Re: another python scripting question

Posted by Aryeh Weiss on Aug 23, 2013; 5:21am
URL: http://imagej.273.s1.nabble.com/another-python-scripting-question-tp5004517p5004540.html

Dear Jan,

Thanks again for your very helpful response.

Besides my replies to your comments (interleaved below), I have some
questions that came up as I progress.

1. The dialog event are of the form:
java.awt.event.TextEvent[TEXT_VALUE_CHANGED] on textfield2
or
java.awt.event.ItemEvent[ITEM_STATE_CHANGED,item=Force an
event,stateChange=DESELECTED] on checkbox2

checkbox2 was actually checkbox0 the first time I ran it. Each time I
run, that index increases (eg textfield2 was textfield0 the first time.

I would like these these to be reset each time the script runs, since
then I could test which box or field triggered the event.  However, they
only reset if I leave Fiji. I looked for a method like gd.reset() or
gd.close(), but I did not find this. I also tried "del gd" thinking I
could "erase" all memory of gd (my generic dialog).

Is there a way to "reset" the dialog?

2. How does one cause an image to be the "active" image. I tried
imp.show() (imp is an imagePlus). Is this correct way?


This is a whole new world -- and it is very powerful, and there is a lot
to learn...

On 8/22/13 12:05 PM, Jan Eglinger wrote:
>>> You might also consider using the ExtendedPluginFilter interface, which
>>> provides extended preview functionality.
>>>
>> Is there an example of this in python?
>
> I don't know of any Python example, but there are plenty of Java
> examples in the ImageJ source:
>

Would an ExtendedPluginFilter in python look something like this?

import ij.plugin.filter
class myPlugin(ExtendedPluginFilter)
        def setup(arguments, imp)
                .
                .
                .
        def showDialog(imp, command, pfr)
                .
                .
                .
        def run(ip)
                .
                .
                .

I dont really understand the idea of "implementing an interface".
       
>
> If you finish developing your own python script implementing
> ExtendedPlugInFilter, it would be great if you could add it to Fiji's
> Jython scripting page as an example!
>
> http://fiji.sc/Jython_Scripting
>

How do I post the script?
Actually, my script is very rough, but if I post it, perhaps the experts
can point out to me the many things that are either awkward or wrong,
and it can "evolve" into something much improved. This "evolution",
might provide a useful educational tool in the future.

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