Python Repeated Timer

Python-Repeated-Timer is an open-source & highly performing timer using only standard-libraries.

Users may change the interval and duration of the event as they wish.

This code is GUI freezing issue won't be happening, and performance of the timer won't be affected by any event.

Features:

  • Python Repeated Timer is a open-source library based on Thread Timer, and this asynchronously triggers the event every N seconds.

122346179-a3c20900-cf83-11eb-91a6-8eca01fa4c7d

  • For this only uses python standard-library, no additional library is required.
  • Easy to implement by simply using functions such as start(), stop(). Also, this timer is stable on multiple calls.
  • No matter how heavy timer_tick() is, the timer's interval & duration won't be affected.
  • It is possible to insert the argument so you can customize the timer as you want.
  • You may change the interval & duration of the timer.
  • No freezing issue occurs with GUI libraries such as Tkinter.

Install (~ing)

To install the current release:

$ pip install python-repeated-timer

Usage:

If you want to use a repeated timer in a python code, see this tutorials

$ python

>>> from repeated_timer import Repeated_Timer
>>> def timer_tick(remaining_time: int, *args: tuple, **kwargs: dict):
>>>   # You can put your code in here
>>>   print('timer tick!')
>>>   print(remaining_time)  # You can use remaining_time
>>>
>>> repeated_timer = Repeated_Timer(interval=1, duration=30, function=timer_tick, args1='args1')
>>> repeated_timer.start()
>>> # repeated_timer.stop()

Usage for GUI(with TKinter)

122524359-01715680-d053-11eb-9292-10927552e96c

If you want to use repeated timer with tkinter, see this tutorials

Performance metrics:

this repository is still under construction.

GitHub

https://github.com/takhyun12/python-repeated-timer