slider
pdwidgets.widgets.slider
Slider widget.
Slider(parent, x=0, y=0, w=None, h=None, align=None, align_to=None, fg=None, bg=None, visible=True, value=0.0, padding=None, vertical=False, reverse=False, knob_color=None, step=0.1)
Bases: ProgressBar
Draggable 0–1 value control with a circular knob.
Initialize a Slider widget with a circular knob that can be dragged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
Widget
|
The parent widget or screen that contains this slider. |
required |
x
|
int
|
The x-coordinate of the slider. |
0
|
y
|
int
|
The y-coordinate of the slider. |
0
|
w
|
int
|
The width of the slider. |
None
|
h
|
int
|
The height of the slider. |
None
|
align
|
int
|
The alignment of the slider. |
None
|
align_to
|
Widget
|
The widget to align to. |
None
|
fg
|
int
|
The foreground color of the slider. |
None
|
bg
|
int
|
The background color of the slider. |
None
|
visible
|
bool
|
The visibility of the slider. |
True
|
value
|
float
|
The initial value of the slider (0 to 1). |
0.0
|
padding
|
tuple
|
The padding on each side of the slider. |
None
|
vertical
|
bool
|
Whether the slider is vertical (True) or horizontal (False). |
False
|
reverse
|
bool
|
Whether the slider is reversed (True) or not (False). |
False
|
knob_color
|
int
|
The color of the knob. |
None
|
step
|
float
|
The step size for value adjustments. |
0.1
|
Usage
slider = Slider(screen, vertical=True, step=0.1)
adjust_value(value)
Adjust the slider value by one step in the specified direction.
draw(_=None)
Draw the slider, including the progress bar and the circular knob.
event_callback(data, event)
Handle user input events like clicks, dragging, and mouse movements.