wiki:rp_xml_ele_group
Last modified 2 years ago Last modified on 06/15/13 03:18:25

<group>

A group object groups input elements together.

  <group id="tau">
    <about>
      <label>Minority carrier lifetimes</label>
    </about>

    <number id="taun">
      <about> <label>For electrons</label> </about>
      <default>1e-6</default>
    </number>
    <number id="taup">
      <about> <label>For holes</label> </about>
      <default>1e-6</default>
    </number>
  </group>

By default, the items within a group are arranged in a vertical stack. If you have just a few items in a group and you want to arrange them side by side, you can set the <layout> attribute for the group to horizontal, as follows:

  <group id="tau">
    <about>
      <label>Minority carrier lifetimes</label>
      <layout>horizontal</layout>
    </about>

    <number id="taun">
      <about> <label>For electrons</label> </about>
      <default>1e-6</default>
    </number>
    <number id="taup">
      <about> <label>For holes</label> </about>
      <default>1e-6</default>
    </number>
  </group>

You can also arrange a group of items horizontally, but interspersed with text. To do that, set the layout to sentence: followed by a line of text with placeholders like ${name} where the controls should sit. In the example below, there are two numbers with IDs lat and long in the group. The sentence layout uses ${lat} and ${long} to position the controls within a sentence of text:

<group id="loc">
  <about>
    <layout>sentence:Location = (${lat},${long})</layout>
  </about>

  <number id="lat">
    <about> <label>Latitude</label> </about>
    <default>40.42</default>
  </number>
  <number id="long">
    <about> <label>Longitude</label> </about>
    <default>-86.91</default>
  </number>
</group>


By default, if you have a group containing only group elements, it will be drawn as a set of tabs:

  <group id="tabs">
    <group id="models">
      <about> <label>Models</label> </about>
      ...input elements for this tab...
    </group>

    <group id="ambient">
      <about> <label>Ambient</label> </about>
      <number id="temp">
        <about> <label>Temperature</label> </about>
        <units>K</units>
        <default>300K</default>
      </number>
      ...
    </group>
  </group>

In this case, both models and ambient are groups, so when wrapped within another group, they appear as tabs.

If you want to avoid the tabs and force a vertical (flat) layout of the groups, you can set the layout attribute of the containing group to vertical as follows:

  <group id="tabs">
    <about><layout>vertical</layout></about>

    <group id="models">
      <about> <label>Models</label> </about>
      ...input elements for this tab...
    </group>

    <group id="ambient">
      <about> <label>Ambient</label> </about>
      ...input elements for this tab...
    </group>
  </group>

Or, if the containing group contains anything besides groups (such as a number control, a note, a separator, etc.) then the containing group will fall back on vertical layout instead of using tabs.

You can see working code in the zoo of examples in the group example or on the hub in the directory /apps/rappture/examples/zoo/group.