:right-sidebar: True Timer =================================================================== .. currentmodule:: gi.repository.GLib .. class:: Timer(*args, **kwargs) :no-contents-entry: ``GTimer`` records a start time, and counts microseconds elapsed since that time. This is done somewhat differently on different platforms, and can be tricky to get exactly right, so ``GTimer`` provides a portable/convenient interface. Methods ------- .. rst-class:: interim-class .. class:: Timer :no-index: .. method:: continue_() -> None .. method:: destroy() -> None Destroys a timer, freeing associated resources. .. method:: elapsed(microseconds: int) -> float If ``timer`` has been started but not stopped, obtains the time since the timer was started. If ``timer`` has been stopped, obtains the elapsed time between the time it was started and the time it was stopped. The return value is the number of seconds elapsed, including any fractional part. The ``microseconds`` out parameter is essentially useless. :param microseconds: return location for the fractional part of seconds elapsed, in microseconds (that is, the total number of microseconds elapsed, modulo 1000000), or :const:`None` .. method:: is_active() -> bool Exposes whether the timer is currently active. .. versionadded:: 2.62 .. method:: reset() -> None This function is useless; it's fine to call :func:`~gi.repository.GLib.Timer.start` on an already-started timer to reset the start time, so :func:`~gi.repository.GLib.Timer.reset` serves no purpose. .. method:: start() -> None Marks a start time, so that future calls to :func:`~gi.repository.GLib.Timer.elapsed` will report the time since :func:`~gi.repository.GLib.Timer.start` was called. :func:`~gi.repository.GLib.Timer.new` automatically marks the start time, so no need to call :func:`~gi.repository.GLib.Timer.start` immediately after creating the timer. .. method:: stop() -> None Marks an end time, so calls to :func:`~gi.repository.GLib.Timer.elapsed` will return the difference between this end time and the start time.