AbstractSliderMixin
Base classes
Name |
Children |
Inherits |
WidgetMixin prettyqt.widgets.widget
|
|
|
Subclasses
Class |
Module |
Description |
AbstractSlider |
prettyqt.widgets.abstractslider |
|
ScrollBarMixin |
prettyqt.widgets.scrollbar |
|
Slider |
prettyqt.widgets.slider |
|
Dial |
prettyqt.widgets.dial |
|
â‹” Inheritance diagram
graph TD
1473293701904["widgets.AbstractSliderMixin"]
1473293688240["widgets.WidgetMixin"]
1473299815024["core.ObjectMixin"]
140713234304496["builtins.object"]
1473245548480["gui.PaintDeviceMixin"]
1473293688240 --> 1473293701904
1473299815024 --> 1473293688240
140713234304496 --> 1473299815024
1473245548480 --> 1473293688240
140713234304496 --> 1473245548480
🛈 DocStrings
Bases: WidgetMixin
Source code in prettyqt\widgets\abstractslider.py
| class AbstractSliderMixin(widgets.WidgetMixin):
value_changed = core.Signal(int)
def _get_map(self):
maps = super()._get_map()
maps |= {
"orientation": constants.ORIENTATION,
}
return maps
def on_value_change(self):
self.value_changed.emit(self.value())
def is_horizontal(self) -> bool:
"""Check if silder is horizontal.
Returns:
True if horizontal, else False
"""
return self.orientation() == constants.HORIZONTAL
def is_vertical(self) -> bool:
"""Check if silder is vertical.
Returns:
True if vertical, else False
"""
return self.orientation() == constants.VERTICAL
def set_horizontal(self):
"""Set slider orientation to horizontal."""
self.setOrientation(constants.HORIZONTAL)
def set_vertical(self):
"""Set slider orientation to vertical."""
self.setOrientation(constants.VERTICAL)
def set_orientation(
self, orientation: constants.OrientationStr | constants.Orientation
):
"""Set the orientation of the slider.
Args:
orientation: orientation for the slider
"""
self.setOrientation(constants.ORIENTATION.get_enum_value(orientation))
def get_orientation(self) -> constants.OrientationStr:
"""Return current orientation.
Returns:
orientation
"""
return constants.ORIENTATION.inverse[self.orientation()]
def scroll_to_min(self):
"""Scroll to the minimum value of the slider."""
self.setValue(self.minimum())
def scroll_to_max(self):
"""Scroll to the maximum value of the slider."""
self.setValue(self.maximum())
def set_range(self, min_val: int, max_val: int):
self.setRange(min_val, max_val)
def set_step_size(self, step_size: int):
self.setSingleStep(step_size)
def set_repeat_action(
self,
action: SliderActionStr | widgets.QAbstractSlider.SliderAction,
threshold: int = 500,
repeat_time: int = 50,
):
"""Set the repeat action.
Args:
action: repeat action
threshold: initial delay in ms
repeat_time: repeat time in ms
"""
self.setRepeatAction(SLIDER_ACTION.get_enum_value(action), threshold, repeat_time)
def get_repeat_action(self) -> SliderActionStr:
"""Get current repeat action.
Returns:
current repeat action
"""
return SLIDER_ACTION.inverse[self.repeatAction()]
def trigger_action(
self, action: SliderActionStr | widgets.QAbstractSlider.SliderAction
):
"""Trigger slider action."""
self.triggerAction(SLIDER_ACTION.get_enum_value(action))
def get_value(self) -> int:
return self.value()
def set_value(self, value: int):
self.setValue(value)
def on_scrollbar_range_changed(self, minval: int, maxval: int):
if self.value() >= self.maximum() - 1:
self.setValue(maxval)
def set_auto_scroll_to_end(self, scroll: bool = True):
"""Set to always scroll to the end when range changes."""
if scroll:
self.rangeChanged.connect(self.on_scrollbar_range_changed)
else:
self.rangeChanged.disconnect(self.on_scrollbar_range_changed)
|
Return current orientation.
Source code in prettyqt\widgets\abstractslider.py
| def get_orientation(self) -> constants.OrientationStr:
"""Return current orientation.
Returns:
orientation
"""
return constants.ORIENTATION.inverse[self.orientation()]
|
Get current repeat action.
Source code in prettyqt\widgets\abstractslider.py
| def get_repeat_action(self) -> SliderActionStr:
"""Get current repeat action.
Returns:
current repeat action
"""
return SLIDER_ACTION.inverse[self.repeatAction()]
|
Check if silder is horizontal.
Source code in prettyqt\widgets\abstractslider.py
| def is_horizontal(self) -> bool:
"""Check if silder is horizontal.
Returns:
True if horizontal, else False
"""
return self.orientation() == constants.HORIZONTAL
|
Check if silder is vertical.
Source code in prettyqt\widgets\abstractslider.py
| def is_vertical(self) -> bool:
"""Check if silder is vertical.
Returns:
True if vertical, else False
"""
return self.orientation() == constants.VERTICAL
|
Scroll to the maximum value of the slider.
Source code in prettyqt\widgets\abstractslider.py
| def scroll_to_max(self):
"""Scroll to the maximum value of the slider."""
self.setValue(self.maximum())
|
Scroll to the minimum value of the slider.
Source code in prettyqt\widgets\abstractslider.py
| def scroll_to_min(self):
"""Scroll to the minimum value of the slider."""
self.setValue(self.minimum())
|
Set to always scroll to the end when range changes.
Source code in prettyqt\widgets\abstractslider.py
| def set_auto_scroll_to_end(self, scroll: bool = True):
"""Set to always scroll to the end when range changes."""
if scroll:
self.rangeChanged.connect(self.on_scrollbar_range_changed)
else:
self.rangeChanged.disconnect(self.on_scrollbar_range_changed)
|
Set slider orientation to horizontal.
Source code in prettyqt\widgets\abstractslider.py
| def set_horizontal(self):
"""Set slider orientation to horizontal."""
self.setOrientation(constants.HORIZONTAL)
|
Set the orientation of the slider.
Parameters:
Name |
Type |
Description |
Default |
orientation |
OrientationStr | Orientation
|
orientation for the slider
|
required
|
Source code in prettyqt\widgets\abstractslider.py
| def set_orientation(
self, orientation: constants.OrientationStr | constants.Orientation
):
"""Set the orientation of the slider.
Args:
orientation: orientation for the slider
"""
self.setOrientation(constants.ORIENTATION.get_enum_value(orientation))
|
Set the repeat action.
Parameters:
Name |
Type |
Description |
Default |
action |
SliderActionStr | SliderAction
|
|
required
|
threshold |
int
|
|
500
|
repeat_time |
int
|
|
50
|
Source code in prettyqt\widgets\abstractslider.py
| def set_repeat_action(
self,
action: SliderActionStr | widgets.QAbstractSlider.SliderAction,
threshold: int = 500,
repeat_time: int = 50,
):
"""Set the repeat action.
Args:
action: repeat action
threshold: initial delay in ms
repeat_time: repeat time in ms
"""
self.setRepeatAction(SLIDER_ACTION.get_enum_value(action), threshold, repeat_time)
|
Set slider orientation to vertical.
Source code in prettyqt\widgets\abstractslider.py
| def set_vertical(self):
"""Set slider orientation to vertical."""
self.setOrientation(constants.VERTICAL)
|
Trigger slider action.
Source code in prettyqt\widgets\abstractslider.py
| def trigger_action(
self, action: SliderActionStr | widgets.QAbstractSlider.SliderAction
):
"""Trigger slider action."""
self.triggerAction(SLIDER_ACTION.get_enum_value(action))
|