Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add task listing with time (in seconds)

  • Loading branch information...
commit a4bcbf4fd5280ba29332971bedb88a6485d60720 1 parent 912e926
@mhitza authored
Showing with 28 additions and 13 deletions.
  1. +28 −13 TimeState.py
View
41 TimeState.py
@@ -5,6 +5,7 @@
import pygtk
pygtk.require('2.0')
import gtk
+import gobject
class TimeState:
def __init__(self):
@@ -33,15 +34,14 @@ def stopTracking(self):
previous, start = self.timesheet[oldTask]
self.timesheet[oldTask] = (int(time.time()) - start + previous, None)
- def printTasks(self, rebase=None):
+ def getTasks(self, rebase=None):
if rebase is not None:
items = self.rebase(self.timesheet.items(), rebase)
else:
items = self.timesheet.items()
- for k,v in items:
- total, _ = v
- print "{} : {}".format(k, float(total/60/60))
+ # TODO have the hour division back in after testing
+ return map(lambda v: (v[0], float(v[1][0])), items)
def rebase(self, items, rebase):
current_sum = sum(map(lambda x: x[1][0], items()))
@@ -59,29 +59,44 @@ def destroy(self, widget, data=None):
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
- self.timestate = TimeState()
-
self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(10)
+ self.window.set_default_size(300, 400)
self.window.set_resizable(True)
- self.hbox = gtk.HBox(True, 10)
+ self.vbox = gtk.VBox(False, 10)
+ self.vbox.show()
+ self.hbox = gtk.HBox(False, 10)
+ self.hbox.show()
+
+ self.listStore = gtk.ListStore(str, int)
+ self.treeView = gtk.TreeView(self.listStore)
+ self.treeView.set_rules_hint(True)
+ self.treeView.append_column(gtk.TreeViewColumn("Task", gtk.CellRendererText(), text=0))
+ self.treeView.append_column(gtk.TreeViewColumn("Time", gtk.CellRendererText(), text=1))
+ self.treeView.show()
+
+ self.timestate = TimeState()
self.entry = gtk.Entry()
+ self.entry.show()
+
self.button = gtk.Button("Track task")
+ self.button.show()
def trackTimeState(w, d):
self.timestate.track(self.entry.get_text())
self.entry.set_text('')
-
+ self.listStore.clear()
+ for v in self.timestate.getTasks():
+ self.listStore.append(v)
self.button.connect('clicked', trackTimeState, None)
-
+
self.hbox.add(self.entry)
self.hbox.add(self.button)
+ self.vbox.pack_start(self.hbox, False)
+ self.vbox.add(self.treeView)
- self.window.add(self.hbox)
- self.hbox.show()
- self.entry.show()
- self.button.show()
+ self.window.add(self.vbox)
self.window.show()
def main(self):
Please sign in to comment.
Something went wrong with that request. Please try again.