Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add task listing with time (in seconds)

  • Loading branch information...
commit a4bcbf4fd5280ba29332971bedb88a6485d60720 1 parent 912e926
Marius Ghita authored

Showing 1 changed file with 28 additions and 13 deletions. Show diff stats Hide diff stats

  1. +28 13 TimeState.py
41 TimeState.py
@@ -5,6 +5,7 @@
5 5 import pygtk
6 6 pygtk.require('2.0')
7 7 import gtk
  8 +import gobject
8 9
9 10 class TimeState:
10 11 def __init__(self):
@@ -33,15 +34,14 @@ def stopTracking(self):
33 34 previous, start = self.timesheet[oldTask]
34 35 self.timesheet[oldTask] = (int(time.time()) - start + previous, None)
35 36
36   - def printTasks(self, rebase=None):
  37 + def getTasks(self, rebase=None):
37 38 if rebase is not None:
38 39 items = self.rebase(self.timesheet.items(), rebase)
39 40 else:
40 41 items = self.timesheet.items()
41 42
42   - for k,v in items:
43   - total, _ = v
44   - print "{} : {}".format(k, float(total/60/60))
  43 + # TODO have the hour division back in after testing
  44 + return map(lambda v: (v[0], float(v[1][0])), items)
45 45
46 46 def rebase(self, items, rebase):
47 47 current_sum = sum(map(lambda x: x[1][0], items()))
@@ -59,29 +59,44 @@ def destroy(self, widget, data=None):
59 59
60 60 def __init__(self):
61 61 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
62   - self.timestate = TimeState()
63   -
64 62 self.window.connect("delete_event", self.delete_event)
65 63 self.window.connect("destroy", self.destroy)
66 64 self.window.set_border_width(10)
  65 + self.window.set_default_size(300, 400)
67 66 self.window.set_resizable(True)
68 67
69   - self.hbox = gtk.HBox(True, 10)
  68 + self.vbox = gtk.VBox(False, 10)
  69 + self.vbox.show()
  70 + self.hbox = gtk.HBox(False, 10)
  71 + self.hbox.show()
  72 +
  73 + self.listStore = gtk.ListStore(str, int)
  74 + self.treeView = gtk.TreeView(self.listStore)
  75 + self.treeView.set_rules_hint(True)
  76 + self.treeView.append_column(gtk.TreeViewColumn("Task", gtk.CellRendererText(), text=0))
  77 + self.treeView.append_column(gtk.TreeViewColumn("Time", gtk.CellRendererText(), text=1))
  78 + self.treeView.show()
  79 +
  80 + self.timestate = TimeState()
70 81 self.entry = gtk.Entry()
  82 + self.entry.show()
  83 +
71 84 self.button = gtk.Button("Track task")
  85 + self.button.show()
72 86 def trackTimeState(w, d):
73 87 self.timestate.track(self.entry.get_text())
74 88 self.entry.set_text('')
75   -
  89 + self.listStore.clear()
  90 + for v in self.timestate.getTasks():
  91 + self.listStore.append(v)
76 92 self.button.connect('clicked', trackTimeState, None)
77   -
  93 +
78 94 self.hbox.add(self.entry)
79 95 self.hbox.add(self.button)
  96 + self.vbox.pack_start(self.hbox, False)
  97 + self.vbox.add(self.treeView)
80 98
81   - self.window.add(self.hbox)
82   - self.hbox.show()
83   - self.entry.show()
84   - self.button.show()
  99 + self.window.add(self.vbox)
85 100 self.window.show()
86 101
87 102 def main(self):

0 comments on commit a4bcbf4

Please sign in to comment.
Something went wrong with that request. Please try again.