JMRI: Jynstruments
JMRI provides a nice way to integrate Jython scripts in the JMRI Java application, particularly aimed at extending and customising the GUI.That is called a Jynstrument. It's a bundle of Jython code and other resources. The Jython code defines an object deriving from the Java Jynstrument class (itself deriving from JPanel). This object will be instantiated by the instrumented JMRI code itself and then is event driven.
Have a look at the
Jython folder
in your source tree,
there is
Jynstruments folder
with a
README
and a
ThrottleFrame/Light.jyn
to be tried on the JMRI Throttle window.
The image to the right shows them in use (the diamond buttons).
In the Jython folder, you'll also find a simple Test.jyn for testing purpose.
See ThrottleFrame.java for how to make code instrumentable; more details are in the README.
Usage is quite simple, drag'n drop the Light.jyn folder
onto a JMRI Throttle Window
(on window content itself, the toolbar is instrumentable too,
but won't accept the Lights.jyn).
Once the Jynstrument is started, the GUI will update, a Jynstrument
property menu is accesible by right clicking on the Jynstrument or its
border. From this menu you can Remove the Jynstrument, or view its Ouput.
See the content of the Jynstrument itself (comments in the .py file) for specific informations about them.
Several parts of JMRI are Jynstrumentable today:
- The JMRI main Window were you can add launchers.
- The JMRI Throttle Window where you can add Jynstruments to enrich the curent throttle experience.
- The JMRI Throttle Windows toolbar that allows for Jynstruments that will pilot all the Throttles in that Window (paritcularly with special controllers)