python - How do I make a stopwatch that continues to run even after closing the application? -
i'd create stopwatch of-sorts records duration elapsed specific moment in time. save database. when close application , reload application i'd able see time elapsed since specific moment in time timer initiated. i'd able see days elapsed well. best way of going this?
you can put timer code in thread, work deamon , , record time:
class timethread(threading.thread): stop = 0 def __init__(self): threading.thread.__init__(self) def run(self): # here code timer #you can put condition insert db! def stop(self): self.__stop = true print 'in stop' self.stop = 1
to start thread, in background deamon, this:
f_thread = timethread() f_thread.start()
Comments
Post a Comment