Skip to content, Skip to search

Changes

Jython Scripting

95 bytes added, 12 February
m
Self written Jython packages for ImageJ: Simpler reformulation
== Self written Jython packages for ImageJ ==
On the way to perfectly organize Jython code, [https://docs.python.org/2/tutorial/modules.html#packages packages] are the next step. In A Jython, folders package is a folder that contain a set of modules are made packages by adding the file scripts together with a <code>__init__.py</code>file. This file can be empty. An Below is a typical structure for the <code>Imagej.app/jars/Lib</code> folder structure can look like this:
<source>
</source>
The reason for the last import to fail is the empty <code>__init__.py</code>. We have to define which modules of the package are imported when using <code>import *</code>. This is done by setting the variable <code>__all__</code> at in the <code>__init__.py</code>. For <code>myPackage2</code> this line of code is needed:
<source lang='python'>
</source>
Besides setting this variable, the <code>__init__.py</code> file can contain normal Jython code that is executed on upon importof the package.
== Bundle packages in a JAR file ==
47
edits