trying to add projects to the table
This commit is contained in:
parent
416a9f35bd
commit
c562f471bc
29
Window.py
29
Window.py
@ -27,6 +27,8 @@ class Window:
|
||||
self.menubar.append(mi)
|
||||
|
||||
# Projects Table
|
||||
self.projects_present = False
|
||||
self.projects_container = gtk.VBox()
|
||||
self.updateProjects()
|
||||
|
||||
# Bottom Control Bar
|
||||
@ -43,17 +45,23 @@ class Window:
|
||||
|
||||
vbox = gtk.VBox()
|
||||
vbox.pack_start(self.menubar)
|
||||
vbox.pack_start(self.projects_table)
|
||||
vbox.pack_start(self.projects_container)
|
||||
vbox.pack_start(gtk.HSeparator())
|
||||
vbox.pack_start(hbox)
|
||||
|
||||
self.window.add(vbox)
|
||||
|
||||
def updateProjects(self):
|
||||
if self.projects_present:
|
||||
self.projects_container.remove(self.projects_table)
|
||||
self.projects = self.ds.getProjects()
|
||||
projects_to_show = {}
|
||||
for p in self.shown_projects:
|
||||
projects_to_show[p] = 1
|
||||
col_headers = ('Project',
|
||||
'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Tot')
|
||||
self.projects_table = gtk.Table(rows = 2, columns = len(col_headers))
|
||||
rows = 2 + len(projects_to_show)
|
||||
self.projects_table = gtk.Table(rows = rows, columns = len(col_headers))
|
||||
|
||||
self.new_project_combobox = gtk.combo_box_entry_new_text()
|
||||
self.new_project_combobox.connect("key-release-event",
|
||||
@ -71,17 +79,28 @@ class Window:
|
||||
l.set_size_request(35 if i > 0 else 200, -1)
|
||||
self.projects_table.attach(l, i, i + 1, 0, 1)
|
||||
|
||||
self.projects_table.attach(self.new_project_combobox, 0, 1, 1, 2)
|
||||
row = 1
|
||||
for p in projects_to_show:
|
||||
self.projects_table.attach(gtk.Label(p), 0, 1, row, row + 1)
|
||||
|
||||
self.projects_table.attach(self.new_project_combobox, 0, 1,
|
||||
rows - 1, rows)
|
||||
hbox = gtk.HBox()
|
||||
hbox.pack_start(self.add_project_button, expand = False)
|
||||
self.projects_table.attach(hbox, 1, 9, 1, 2)
|
||||
self.projects_table.attach(hbox, 1, 9, rows - 1, rows)
|
||||
self.projects_container.pack_start(self.projects_table)
|
||||
self.projects_present = True
|
||||
|
||||
def main(self):
|
||||
self.window.show_all()
|
||||
gtk.main()
|
||||
|
||||
def add_project_event(self, button, data=None):
|
||||
print "text:", self.new_project_combobox.get_active_text()
|
||||
pname = self.new_project_combobox.get_active_text()
|
||||
if not pname in self.projects.values():
|
||||
self.ds.createProject(pname)
|
||||
self.shown_projects.append(pname)
|
||||
self.updateProjects()
|
||||
|
||||
def project_key_press_event(self, widget, event, data=None):
|
||||
if event.keyval == gtk.gdk.keyval_from_name("Return"):
|
||||
|
Loading…
x
Reference in New Issue
Block a user