Skip to content

Timer

Qt Base Class: QTimer

Signature: QTimer(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
ObjectMixin
prettyqt.core.object
QTimer
PySide6.QtCore
QTimer(self, parent: Optional[PySide6.QtCore.QObject] \= None) -> None

Subclasses

Class Module Description
AnimationTimer prettyqt.animations.fx

⋔ Inheritance diagram

graph TD
  1473299862848["core.Timer"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473288845168["QtCore.QTimer"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473299815024 --> 1473299862848
  140713234304496 --> 1473299815024
  1473288845168 --> 1473299862848
  1473288842240 --> 1473288845168
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: ObjectMixin, QTimer

Repetitive and single-shot timers.

Source code in prettyqt\core\timer.py
class Timer(core.ObjectMixin, core.QTimer):
    """Repetitive and single-shot timers."""

    def _get_map(self):
        maps = super()._get_map()
        maps |= {"timerType": constants.TIMER_TYPE}
        return maps

    def set_type(self, typ: constants.TimerTypeStr | constants.TimerType):
        """Set the timer type.

        Args:
            typ: timer type
        """
        self.setTimerType(constants.TIMER_TYPE.get_enum_value(typ))

    def get_type(self) -> constants.TimerTypeStr:
        """Return current timer type.

        Returns:
            timer type
        """
        return constants.TIMER_TYPE.inverse[self.timerType()]

    def set_interval(self, interval: int | str):
        if isinstance(interval, str):
            interval = helpers.parse_time(interval)
        self.setInterval(interval)

    def start_timer(self, interval: None | int | str = None):
        if isinstance(interval, str):
            interval = helpers.parse_time(interval)
        if interval is None:
            self.start()
        else:
            self.start(interval)

    def restart(self):
        self.stop()
        self.start()

get_type() -> constants.TimerTypeStr

Return current timer type.

Source code in prettyqt\core\timer.py
def get_type(self) -> constants.TimerTypeStr:
    """Return current timer type.

    Returns:
        timer type
    """
    return constants.TIMER_TYPE.inverse[self.timerType()]

set_type(typ: constants.TimerTypeStr | constants.TimerType)

Set the timer type.

Parameters:

Name Type Description Default
typ TimerTypeStr | TimerType

timer type

required
Source code in prettyqt\core\timer.py
def set_type(self, typ: constants.TimerTypeStr | constants.TimerType):
    """Set the timer type.

    Args:
        typ: timer type
    """
    self.setTimerType(constants.TIMER_TYPE.get_enum_value(typ))

⌗ Property table

Qt Property Type Doc
objectName QString
singleShot bool
interval int
remainingTime int
timerType Qt::TimerType
active bool