Files
2026-06-17 14:00:51 +02:00

85 lines
4.2 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta name="generator" content="HTML Tidy for HTML5 for Apple macOS version 5.8.0">
<title>JMRI: Jynstruments</title><!--#include virtual="/help/en/parts/Style.shtml" -->
</head>
<body>
<!--#include virtual="/help/en/parts/Header.shtml" -->
<div id="mBody">
<!--#include virtual="Sidebar.shtml" -->
<div id="mainContent">
<h1>JMRI: Jynstruments</h1>
JMRI provides a nice way to integrate Jython scripts in the JMRI Java application,
particularly aimed at extending and customising the GUI.
<p>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.</p>
<p><a href="images/throttleWindowJynstrumented.png"><img style=
"border: 0px solid ; width: 369px; height: 215px;" alt="Fully Jysntrumented Throttle Window"
src="images/throttleWindowJynstrumented.png"></a> Have a look at the <a href=
"https://www.jmri.org/jython/">Jython folder</a> in your source tree, there is <a href=
"https://www.jmri.org/jython/Jynstruments/">Jynstruments folder</a> with a <a href=
"https://www.jmri.org/jython/Jynstruments/README">README</a> and a <a href=
"https://www.jmri.org/jython/Jynstruments/ThrottleFrame/Light.jyn/">ThrottleFrame/Light.jyn</a> to
be tried on the JMRI Throttle window. The image to the right shows them in use (the diamond
buttons).<br>
In the Jython folder, you'll also find a simple <a href=
"https://www.jmri.org/jython/Jynstruments/Test.jyn/">Test.jyn</a> for testing purpose.<br></p>
<p>See ThrottleFrame.java for how to make code instrumentable; more details are in the
README.</p>
<p>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).<br></p>
<p>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.<br></p>
<p><img style="width: 355px; height: 216px;" src=
"images/mainWindowJynstrumentContextMenu.png" alt="mainWindowJynstrumentContextMenu.png">
</p>
<p>See the content of the Jynstrument itself (comments in the .py file) for specific
informations about them.<br></p>
<p>Several parts of JMRI are Jynstrumentable today:</p>
<ul>
<li>The JMRI main Window were you can add <a href=
"https://www.jmri.org/jython/Jynstruments/Launchers/">launchers</a>. There is a Jython script
named JynstrumentMainFrame.py in the JMRI default Jython script folder that shows how to
load these Launchers from a regular JMRI Jython script, then you can select this script to
be automatically executed at JMRI startup (from JMRI preferences) in order to have JMRI
main window customised the way you like.
</li>
<li>The <a href="../throttle/BasicThrottleWindow.shtml">JMRI Throttle Window</a> where you
can add Jynstruments <a href="https://www.jmri.org/jython/Jynstruments/ThrottleFrame/">to
enrich the curent throttle experience</a> (special functions, e-stop, directions... and
even one that will display video from a video capture device, like a Bluetooth webcam
mounted on a train). Do not hesitate to write your own special function Jynstruments,
that's what Jynstrument are meant for.<br>
</li>
<li>The <a href="../throttle/ThrottleToolBar.shtml">JMRI Throttle Windows toolbar</a> that
allows for Jynstruments that will <a href=
"https://www.jmri.org/jython/Jynstruments/ThrottleWindowToolBar/">pilot all the Throttles in
that Window</a> (particularly with special controllers)<br>
</li>
</ul>
<!--#include virtual="/help/en/parts/Footer.shtml" -->
</div>
<!-- closes #mainContent-->
</div>
<!-- closes #mBody-->
<script src="/js/help.js"></script>
</body>
</html>