`slider()` creates a numeric slider.
Creates a slider object.
| Item | Description |
|---|---|
| Syntax | `slider()` |
| Arguments | none |
| Returns | slider object |
Example:
s = slider().range(0, 100, 1).value(50);
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. |
| `value` | number | Current slider value. |
| `min` | number | Current minimum. |
| `max` | number | Current maximum. |
| `interval` | number | Current slider interval. |
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 `slider`.
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 current slider value. Value is clamped to the current range. If the value changes, the change callback is called.
| Item | Description |
|---|---|
| Syntax | `slider.value(value)` |
| Arguments | `value`: numeric slider value |
| Returns | slider object |
Example:
s = slider().range(0, 100, 1).value(50);
Sets minimum, maximum, and interval. If `min` is greater than `max`, the values are swapped. If `step` is `0` or negative, interval becomes `0.1`.
The current value is clamped to the new range.
| Item | Description |
|---|---|
| Syntax | `slider.range(min, max, step)` |
| Arguments | `min`: minimum value; `max`: maximum value; `step`: interval |
| Returns | slider object |
Example:
s = slider().range(0, 100, 5);
Sets a callback called when slider value changes.
| Item | Description |
|---|---|
| Syntax | `slider.on_change(callback)` |
| Arguments | `callback`: callable with one argument, the current slider value |
| Returns | slider object |
Example:
function feed_changed(value) { print('feed: ', value); } s = slider().on_change(feed_changed);