Welcome, guest | Sign In | My Account | Store | Cart

This recipe demonstrates the use of the "Aens Time" module. It is imported here as "aens_time" and shown in a very simple role of updating a string after one "mille" passes. The results for this demonstration is a quickly updating clock.

Python, 18 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import aens_time
import Tkinter

def main():
    root = Tkinter.Tk()
    root.resizable(False, False)
    root.title('Aens Time')
    string = Tkinter.StringVar()
    Tkinter.Label(textvariable=string, font=('helvetica', 16, 'bold')).grid(padx=5, pady=5)
    thread = aens_time.Mille_Timer(update, string)
    thread.start()
    root.mainloop()

def update(string):
    string.set(aens_time.format(aens_time.seconds()))

if __name__ == '__main__':
    main()

The most useful feature of the aens_time module is that the Mille_Timer class presents a self-checking timing interface. If the function being executed takes too long to complete, then an exception will be raised; and the timer thread will crash.