Slider

class Slider[source]

Bases: BoundComponent

This component creates a customizable slider widget that can be bound to an object’s attribute (either a dictionary key or object attribute). When the value changes, it automatically updates the bound attribute and optionally calls a action function.

Parameters:
objUnion[object, dict], optional

The object or dictionary containing the attribute to be edited. If None, the slider operates with the provided value parameter.

attrstr, optional

The name of the attribute/key to be edited. If None, the slider operates with the provided value parameter.

valuefloat, optional

The initial value for the slider when not bound to an object attribute. Defaults to 0.

titlestr, optional

Label displayed above the slider. If None, uses the attr name or “Value” if attr is None.

min_valfloat, optional

Minimum value of the slider. Defaults to 0.

max_valfloat, optional

Maximum value of the slider. Defaults to 100.

stepfloat, optional

Step size of the slider. Defaults to 1.

tick_intervalfloat, optional

Interval between tick marks. No ticks if None. Defaults to None.

actionCallable[[Component, float], None], optional

A function to call when the value changes. Receives the component and new value.

**kwargs

Additional keyword arguments passed to BoundComponent, including: - watch_interval : int, optional

Interval in milliseconds to check for changes in the bound object. If None, watching is disabled. Default is 100.

Attributes:
objUnion[object, dict]

The object or dictionary containing the attribute being edited.

attrstr

The name of the attribute/key being edited.

actionCallable[[Component, float], None] or None

The action function to call when the value changes.

widgetQWidget

The main widget containing the slider layout.

titlestr

Label displayed above the slider.

min_valfloat

Minimum value of the slider.

max_valfloat

Maximum value of the slider.

stepfloat

Step size of the slider.

layoutQVBoxLayout

Layout of the widget.

sliderQSlider

Slider widget.

value_labelQLabel

Label displaying the current value of the slider.

line_editQLineEdit

Text input field for direct value entry.

Methods

on_slider_changed

Handle slider value changes.

on_text_changed

Handle text input changes.

sync_from_bound_object

Sync the slider and text input with the bound object's value.

Inherited Methods

get_attr

Get the current value of the bound attribute.

on_value_changed

Handle value changes for the bound attribute.

set_attr

Set the value of the bound attribute.

set_watch_interval

Set or change the watch interval.

start_watching

Start watching the bound object for changes.

stop_watching

Stop watching the bound object for changes.

update