add timer to update status label

This commit is contained in:
Josh Holtrop 2011-03-19 22:02:19 -04:00
parent 2262d2c92a
commit 3a4e23f7d4

View File

@ -28,6 +28,8 @@ class Window:
self.window.connect("destroy", self.destroy_event) self.window.connect("destroy", self.destroy_event)
self.window.connect("key-press-event", self.window_key_press_event) self.window.connect("key-press-event", self.window_key_press_event)
gobject.timeout_add(1000, self.update_status_event)
# Menu Bar # Menu Bar
self.menubar = gtk.MenuBar() self.menubar = gtk.MenuBar()
m = gtk.Menu() m = gtk.Menu()
@ -383,3 +385,14 @@ class Window:
def show_about_event(self, widget, data=None): def show_about_event(self, widget, data=None):
about_window = AboutWindow() about_window = AboutWindow()
def update_status_event(self):
if self.mark is not None:
td = datetime.now() - self.mark
days = td.days
hours = td.seconds / 60 / 60
mins = (td.seconds - hours * 60 * 60) / 60
secs = (td.seconds - hours * 60 * 60 - mins * 60)
self.status_label.set_text('Mark: %s; Elapsed: %dd %dh %dm %ds' % \
(self.mark.strftime(DT_FORMAT), days, hours, mins, secs))
return True