Often in computer programs there would be a requirement to execute a function/task after certain time has passed. And some times this task could be a repetitive one, that needs to be executed again and again after certain interval has elapsed. A simple example is, in VoIP applications a phone is required to send a voice packet every 20 milliseconds. In GUI application a clock needs to be displayed in which updates it self every second displaying time elapsed or current time. For all such cases a timer is best suited tool.
Python standard library provides a Timer class that is capable of executing task in single shot mode. However, thats a very basic functionality that a timer could provide. The external GUI and Network frameworks of python provide extensive timers with fancy provisions. I'll provide a list of timer APIs provided by vairous python libraries that I've come across.
Python standard library provides a Timer class that is capable of executing task in single shot mode. However, thats a very basic functionality that a timer could provide. The external GUI and Network frameworks of python provide extensive timers with fancy provisions. I'll provide a list of timer APIs provided by vairous python libraries that I've come across.
- after method of Tkinter librarie's mainwindow (ships with standard library on windows, again minimal functionality one)
- wx.Timer , wx.CallLater , wx.PyTimer these are various timers provided by wxPython library. The CallLater and PyTimer are convenience functions built on top of wx.Timer
- QTimer is PySide's (PyQt) version of timer functionality. Its neat with various helper functions.
- callLater , LoopingCall are the timer APIs provided by the network swiss army knife of python - Twisted library.