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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -