add timer to update status label
This commit is contained in:
parent
2262d2c92a
commit
3a4e23f7d4
13
Window.py
13
Window.py
@ -28,6 +28,8 @@ class Window:
|
||||
self.window.connect("destroy", self.destroy_event)
|
||||
self.window.connect("key-press-event", self.window_key_press_event)
|
||||
|
||||
gobject.timeout_add(1000, self.update_status_event)
|
||||
|
||||
# Menu Bar
|
||||
self.menubar = gtk.MenuBar()
|
||||
m = gtk.Menu()
|
||||
@ -383,3 +385,14 @@ class Window:
|
||||
|
||||
def show_about_event(self, widget, data=None):
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user