Skip to content

SpinBox

Base classes

Name Children Inherits
AbstractSpinBoxMixin
prettyqt.widgets.abstractspinbox
QSpinBox
PySide6.QtWidgets
QSpinBox(self, /, parent: PySide6.QtWidgets.QWidget | None \= None, *, suffix: str | None \= None, prefix: str | None \= None, cleanText: str | None \= None, minimum: int | None \= None, maximum: int | None \= None, singleStep: int | None \= None, stepType: PySide6.QtWidgets.QAbstractSpinBox.StepType | None \= None, value: int | None \= None, displayIntegerBase: int | None \= None) -> None

⋔ Inheritance diagram

graph TD
  2058972923["widgets.SpinBox"]
  2425936479["widgets.AbstractSpinBoxMixin"]
  829357528["widgets.WidgetMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  625385617["gui.PaintDeviceMixin"]
  2555508520["QtWidgets.QSpinBox"]
  1657700966["QtWidgets.QAbstractSpinBox"]
  3620195106["QtWidgets.QWidget"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  673956333["QtGui.QPaintDevice"]
  2425936479 --> 2058972923
  829357528 --> 2425936479
  3227531497 --> 829357528
  2751680898 --> 3227531497
  625385617 --> 829357528
  2751680898 --> 625385617
  2751680898 --> 829357528
  2751680898 --> 2425936479
  2555508520 --> 2058972923
  1657700966 --> 2555508520
  3620195106 --> 1657700966
  3984060476 --> 3620195106
  37984305 --> 3984060476
  2751680898 --> 37984305
  673956333 --> 3620195106
  37984305 --> 673956333

🛈 DocStrings

Bases: AbstractSpinBoxMixin, QSpinBox

Source code in prettyqt/widgets/spinbox.py
class SpinBox(widgets.AbstractSpinBoxMixin, widgets.QSpinBox):
    value_changed = core.Signal(int)

    def __init__(self, *args, maximum: int = MAX_VAL, **kwargs):
        super().__init__(*args, maximum=maximum, **kwargs)
        self.valueChanged.connect(self.value_changed)

    @classmethod
    def supports(cls, instance) -> bool:
        return isinstance(instance, int)

    def set_range(self, start: int | None, end: int | None):
        self.setMinimum(start)
        self.setMaximum(end)

    setRange = set_range  # noqa: N815

    def set_minimum(self, value: int | None):
        if value is None:
            value = -MAX_VAL
        super().setMinimum(value)

    setMinimum = set_minimum  # noqa: N815

    def set_maximum(self, value: int | None):
        if value is None:
            value = MAX_VAL
        super().setMaximum(value)

    setMaximum = set_maximum  # noqa: N815

    def set_step_size(self, step_size):
        self.setSingleStep(step_size)

:fa-brands-github: Show source on GitHub