Integer Input Example

Location: examples/rappture2/integer/

This example demonstrates the <integer> input type with min/max bounds. Integers are whole numbers with no units.

tool.xml

<?xml version="1.0"?>
<run xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../rappture2web/contract.xsd">
<tool>
  <title>integer (rappture2web)</title>
  <about>Example of a Rappture &lt;integer&gt; object.

Integers are integer values with no units. When you click Simulate, the input integer is echoed to the output.
  </about>
  <command>python3 @tool/integer.py @driver</command>
  <contract>
    <input>
      <integer id="points">
        <about>
          <label>Grid points</label>
          <description>Number of nodes used in the simulation mesh.</description>
        </about>
        <min>10</min>
        <max>1000</max>
        <default>100</default>
      </integer>
    </input>
    <output>
      <integer id="outn"><about><label>Echo of points</label><description>Echoes the selected grid point count.</description></about></integer>
    </output>
  </contract>
</tool>
<input>
  <integer id="points">
    <about>
      <label>Grid points</label>
      <description>Number of nodes used in the simulation mesh.</description>
    </about>
    <min>10</min>
    <max>1000</max>
    <default>100</default>
  </integer>
</input>
</run>

Script

import sys
import rappture2web.rp_library as Rappture

rx = Rappture.PyXml(sys.argv[1])

n = rx['input.(points).current'].value
rx['output.integer(outn).about.label'] = 'Echo of points'
rx['output.integer(outn).current'] = n

rx.close()

Running

rappture2web examples/rappture2/integer/