wijjit.elements.input.slider.Slider
- class wijjit.elements.input.slider.Slider(id=None, classes=None, tab_index=None, min_val=0, max_val=100, value=None, step=1, width=20, float_mode=False, label=None, show_value=True, bind=True)[source]
Slider input element for numeric value selection.
A slider provides a visual bar with a draggable handle for selecting values within a range. Supports keyboard navigation (arrows, home/end) and mouse interaction (click to set, drag to adjust).
- Parameters:
id (
str, optional) – Element identifier for state bindingmin_val (
float, optional) – Minimum value (default: 0)max_val (
float, optional) – Maximum value (default: 100)value (
float, optional) – Initial value (defaults to min_val)step (
float, optional) – Step increment for keyboard navigation (default: 1)width (
int, optional) – Visual width of slider track in characters (default: 20)float_mode (
bool, optional) – If True, value property returns float; if False, returns int (default: False)label (
str, optional) – Optional label displayed before slidershow_value (
bool, optional) – Display current value after slider (default: True)tab_index (int | None)
- Variables:
min_val (
float) – Minimum valuemax_val (
float) – Maximum valuestep (
float) – Step incrementwidth (
int) – Track widthfloat_mode (
bool) – Float mode flagshow_value (
bool) – Show value flagon_change (
callableorNone) – Callback (old_value, new_value) when value changeson_slide_start (
callableorNone) – Callback when drag operation beginson_slide_end (
callableorNone) – Callback when drag operation endsaction (
strorNone) – Action ID to dispatch (set by template extension)bind (
bool) – Whether to auto-bind to state[id] (default: True)
Notes
Keyboard controls: - Left/Right: Decrement/increment by step - Home/End: Jump to min/max value
Mouse controls: - Click on track: Set value at clicked position - Drag handle: Smooth value adjustment
- __init__(id=None, classes=None, tab_index=None, min_val=0, max_val=100, value=None, step=1, width=20, float_mode=False, label=None, show_value=True, bind=True)[source]
Methods
__init__([id, classes, tab_index, min_val, ...])add_class(class_name)Add a CSS class to this element.
apply_props(props)Apply props from a VNode, skipping ephemeral props.
Get ephemeral state for reconciliation.
get_hardware_cursor_position()Absolute screen cell where the hardware terminal cursor should park.
get_height_for_width(width)Return the height this element needs when laid out at
width.Get the intrinsic (preferred) size of the slider.
handle_key(key)Handle keyboard input.
handle_mouse(event)Handle mouse input for click and drag.
has_class(class_name)Check if element has a CSS class.
on_blur()Called when element loses focus.
on_focus()Called when element gains focus.
on_hover_enter()Called when mouse enters element.
on_hover_exit()Called when mouse exits element.
on_mount()Called when element is first added to the element tree.
on_unmount()Called when element is removed from the element tree.
on_update(changed_props)Called when element props are updated during reconciliation.
remove_class(class_name)Remove a CSS class from this element.
Paint memo for the skip-unchanged fast path.
render_to(ctx)Render slider to paint context.
restore_ephemeral_state(state)Restore ephemeral state after reconciliation.
set_bounds(bounds)Set the element's screen bounds.
toggle_class(class_name)Toggle a CSS class on this element.
Attributes
captures_tabWhether this element wants the Tab key instead of focus movement.
parent_frameGet the parent Frame if this element is inside a scrollable frame.
supports_dynamic_sizingWhether this element supports dynamic sizing.
Get current value, cast to int if not float_mode.
- TRACK_CHAR = '─'
- HANDLE_CHAR = '█'
- LEFT_CAP = '├'
- RIGHT_CAP = '┤'
- TRACK_CHAR_ASCII = '-'
- HANDLE_CHAR_ASCII = '#'
- LEFT_CAP_ASCII = '['
- RIGHT_CAP_ASCII = ']'
- render_signature()[source]
Paint memo for the skip-unchanged fast path.
Captures the backing value and range (which fix the handle position), the track width, and the label/value-display flags.
focused(handle color) is folded into_style_signature(). Seewijjit.elements.base.Element.render_signature().- Return type:
- render_to(ctx)[source]
Render slider to paint context.
- Parameters:
ctx (
PaintContext) – Paint context with buffer, style resolver, and boundsstyles (Theme)
classes (This element uses the following theme style)
slider (-)
slider:focus (-)
slider.handle (-)
slider.handle:focus (-)
slider.label (-)
slider.value (-)
- Return type:
None
- get_intrinsic_size()[source]
Get the intrinsic (preferred) size of the slider.
- Returns:
(width, height) based on track width, label, and value display
- Return type:
tuple[int,int]
- handle_key(key)[source]
Handle keyboard input.
- Parameters:
key (
Key) – Key press to handle- Returns:
True if key was handled
- Return type:
- async handle_mouse(event)[source]
Handle mouse input for click and drag.
- Parameters:
event (
MouseEvent) – Mouse event to handle- Returns:
True if event was handled
- Return type: