Skip to content, Skip to search


Jython Scripting

1,002 bytes added, 3 April
Jython basics for ImageJ: Add Hello World
That is why more complex examples are used that are fully functional. Just copy the code to the [[Using_the_Script_Editor|Script Editor]] and try them by yourself. Extensive in-line documentation is used to explain the implementation.
=== Hello World ===
==== - With print ====
There are 2 ways to print some information back to the user.<br>
The first one is a classical python print statement, that will print some information to the console. <br>
<code>print "Hello world"</code><br>
You can print any kind of variable and objects.<br>
<code>print "This is a string followed by an int", 10</code>
NB1 : If used in a plugin, and no console window is open then the printed information will not be visible to the user (contrary to the <code>log</code> function below)
NB2 : Using numerous print statements might slow down the execution time when used in a plugin (not observed when executing from the script interpreter).
==== - With IJ.log() ====
from ij import IJ
IJ.log("Hello world")
IJ.log("This is a string followed by an int " + str(10))
Contrary to the print statement the log function display some output into a log window (newly open if not already open), and accept only a string as argument.
=== Image selection using the GenericDialog class ===