`led()` creates a status indicator.
Creates a led object.
| Item | Description |
|---|---|
| Syntax | `led()` |
| Arguments | none |
| Returns | led object |
Example:
state = led().label('Input').digital(true);
Properties are read-only. Use methods to change GUI object state.
| Property | Type | Description |
|---|---|---|
| `position_x` | number | Current x position. |
| `position_y` | number | Current y position. |
| `size_width` | number | Current width. |
| `size_height` | number | Current height. |
| `visible` | boolean | Current visible state. |
| `enabled` | boolean | Current enabled state. |
| `label` | string | Current label text. |
| `value` | number | Current indicator value. `-1` is disabled and `-2` is warning. |
Returns a display string for the object.
| Item | Description |
|---|---|
| Syntax | `value.to_string()` |
| Arguments | none |
| Returns | string |
Example:
text = value.to_string();
`clone()` is not supported for `led`.
Most visible GUI controls support these methods.
Sets the component position in pixels.
| Item | Description |
|---|---|
| Syntax | `component.position(x, y)` |
| Arguments | `x`: x position; `y`: y position |
| Returns | component object |
Example:
label().position(20, 10);
Sets the component size in pixels. Width and height are clamped to at least `1`.
Some container objects, such as `panel()` and `group()`, use `size(-1, -1)` as a special fit-parent mode.
| Item | Description |
|---|---|
| Syntax | `component.size(width, height)` |
| Arguments | `width`: width in pixels; `height`: height in pixels |
| Returns | component object |
Example:
textinput().size(220, 26);
Shows or hides the component.
| Item | Description |
|---|---|
| Syntax | `component.visible(enabled)` |
| Arguments | `enabled`: boolean |
| Returns | component object |
Example:
status.visible(false);
Enables or disables user interaction with the component.
| Item | Description |
|---|---|
| Syntax | `component.enabled(enabled)` |
| Arguments | `enabled`: boolean |
| Returns | component object |
Example:
run_button.enabled(false);
Sets label text.
| Item | Description |
|---|---|
| Syntax | `led.label(text)` |
| Arguments | `text`: label text |
| Returns | led object |
Example:
state = led().label('Probe');
Sets raw indicator value.
| Item | Description |
|---|---|
| Syntax | `led.value(value)` |
| Arguments | `value`: numeric indicator value |
| Returns | led object |
Example:
state = led().value(0.5);
Shows disabled state. This sets `value` to `-1`.
| Item | Description |
|---|---|
| Syntax | `led.disable()` |
| Arguments | none |
| Returns | led object |
Example:
state.disable();
Shows warning state. This sets `value` to `-2`.
| Item | Description |
|---|---|
| Syntax | `led.warning()` |
| Arguments | none |
| Returns | led object |
Example:
state.warning();
Sets digital on/off state. `true` sets value to `1`, and `false` sets value to `0`.
| Item | Description |
|---|---|
| Syntax | `led.digital(value)` |
| Arguments | `value`: boolean state |
| Returns | led object |
Example:
state = led().digital(true);
Sets analog value.
| Item | Description |
|---|---|
| Syntax | `led.analog(value)` |
| Arguments | `value`: numeric analog value |
| Returns | led object |
Example:
state = led().analog(0.75);
input = led().position(20, 20).size(120, 26).label('Probe').digital(false); window().title('LED').size(180, 100).add(input).show();
Previous: progressbar
Next: separator