[kupfer] scheduler: Add Timer.set_ms to set millisecond timers



commit a81f5aa220874d0c118cc4b77138fee8a95c8473
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Sep 7 00:14:50 2009 +0200

    scheduler: Add Timer.set_ms to set millisecond timers

 kupfer/scheduler.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/scheduler.py b/kupfer/scheduler.py
index de2b8d0..370817e 100644
--- a/kupfer/scheduler.py
+++ b/kupfer/scheduler.py
@@ -46,6 +46,15 @@ class Timer (object):
 		self._current_timer = gobject.timeout_add_seconds(timeout_seconds,
 				self._call)
 
+	def set_ms(self, timeout_milliseconds, callback, *arguments):
+		"""Setup timer to call @timeout_milliseconds in the future.
+		If the timer was previously set, it is postponed
+		"""
+		self.invalidate()
+		self._current_callback = lambda : callback(*arguments)
+		self._current_timer = gobject.timeout_add(timeout_milliseconds,
+				self._call)
+
 	def set_idle(self, callback, *arguments):
 		self.invalidate()
 		self._current_callback = lambda : callback(*arguments)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]