Skip to content

AbstractSpinBoxMixin

Base classes

Name Children Inherits
WidgetMixin
prettyqt.widgets.widget

Subclasses

Class Module Description
AbstractSpinBox prettyqt.widgets.abstractspinbox
SpinBox prettyqt.widgets.spinbox
DoubleSpinBox prettyqt.widgets.doublespinbox
DateTimeEditMixin prettyqt.widgets.datetimeedit Widget for editing dates and times.

⋔ Inheritance diagram

graph TD
  1473293702880["widgets.AbstractSpinBoxMixin"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473293688240 --> 1473293702880
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480

🛈 DocStrings

Bases: WidgetMixin

Source code in prettyqt\widgets\abstractspinbox.py
class AbstractSpinBoxMixin(widgets.WidgetMixin):
    def __init__(self, *args, show_group_separator: bool = True, **kwargs):
        super().__init__(*args, show_group_separator=show_group_separator, **kwargs)
        self.setLineEdit(widgets.LineEdit(parent=self))

    def _get_map(self):
        maps = super()._get_map()
        maps |= {
            "alignment": constants.ALIGNMENTS,
            "buttonSymbols": SYMBOLS,
            "correctionMode": CORRECTION_MODES,
        }
        return maps

    def is_valid(self) -> bool:
        return self.hasAcceptableInput()

    def set_validator(
        self, validator: QtGui.QValidator | widgets.lineedit.ValidatorStr | None, **kwargs
    ) -> QtGui.QValidator:
        return self.lineEdit().set_validator(validator)

    def get_button_symbols(self) -> SymbolStr:
        """Return button symbol type.

        Returns:
            button symbol type
        """
        return SYMBOLS.inverse[self.buttonSymbols()]

    def set_button_symbols(self, mode: SymbolStr | QtWidgets.QSpinBox.ButtonSymbols):
        """Set button symbol type.

        Args:
            mode: button symbol type to use
        """
        self.setButtonSymbols(SYMBOLS.get_enum_value(mode))

    def set_correction_mode(
        self, mode: CorrectionModeStr | QtWidgets.QSpinBox.CorrectionMode
    ):
        """Set correction mode.

        Args:
            mode: correction mode to use
        """
        self.setCorrectionMode(CORRECTION_MODES.get_enum_value(mode))

    def get_correction_mode(self) -> CorrectionModeStr:
        """Return correction mode.

        Returns:
            correction mode
        """
        return CORRECTION_MODES.inverse[self.correctionMode()]

    def set_step_type(self, mode: StepTypeStr | QtWidgets.QSpinBox.StepType):
        """Set step type.

        Args:
            mode: step type to use
        """
        self.setStepType(STEP_TYPES.get_enum_value(mode))

    def get_step_type(self) -> StepTypeStr:
        """Return step type.

        Returns:
            step type
        """
        return STEP_TYPES.inverse[self.stepType()]

    def set_special_value(self, value: str):
        self.setSpecialValueText(value)

    def get_value(self) -> int:
        return self.value()

    def set_value(self, value: int | float):
        self.setValue(value)

get_button_symbols() -> SymbolStr

Return button symbol type.

Source code in prettyqt\widgets\abstractspinbox.py
def get_button_symbols(self) -> SymbolStr:
    """Return button symbol type.

    Returns:
        button symbol type
    """
    return SYMBOLS.inverse[self.buttonSymbols()]

get_correction_mode() -> CorrectionModeStr

Return correction mode.

Source code in prettyqt\widgets\abstractspinbox.py
def get_correction_mode(self) -> CorrectionModeStr:
    """Return correction mode.

    Returns:
        correction mode
    """
    return CORRECTION_MODES.inverse[self.correctionMode()]

get_step_type() -> StepTypeStr

Return step type.

Source code in prettyqt\widgets\abstractspinbox.py
def get_step_type(self) -> StepTypeStr:
    """Return step type.

    Returns:
        step type
    """
    return STEP_TYPES.inverse[self.stepType()]

set_button_symbols(mode: SymbolStr | QtWidgets.QSpinBox.ButtonSymbols)

Set button symbol type.

Parameters:

Name Type Description Default
mode SymbolStr | ButtonSymbols

button symbol type to use

required
Source code in prettyqt\widgets\abstractspinbox.py
def set_button_symbols(self, mode: SymbolStr | QtWidgets.QSpinBox.ButtonSymbols):
    """Set button symbol type.

    Args:
        mode: button symbol type to use
    """
    self.setButtonSymbols(SYMBOLS.get_enum_value(mode))

set_correction_mode(mode: CorrectionModeStr | QtWidgets.QSpinBox.CorrectionMode)

Set correction mode.

Parameters:

Name Type Description Default
mode CorrectionModeStr | CorrectionMode

correction mode to use

required
Source code in prettyqt\widgets\abstractspinbox.py
def set_correction_mode(
    self, mode: CorrectionModeStr | QtWidgets.QSpinBox.CorrectionMode
):
    """Set correction mode.

    Args:
        mode: correction mode to use
    """
    self.setCorrectionMode(CORRECTION_MODES.get_enum_value(mode))

set_step_type(mode: StepTypeStr | QtWidgets.QSpinBox.StepType)

Set step type.

Parameters:

Name Type Description Default
mode StepTypeStr | StepType

step type to use

required
Source code in prettyqt\widgets\abstractspinbox.py
def set_step_type(self, mode: StepTypeStr | QtWidgets.QSpinBox.StepType):
    """Set step type.

    Args:
        mode: step type to use
    """
    self.setStepType(STEP_TYPES.get_enum_value(mode))