From 3eaeaa831365f84d4e62f0797f98cb99bbfa3a28 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 21 Feb 2011 22:14:31 -0500 Subject: [PATCH] add Window.updateProjects() --- Window.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Window.py b/Window.py index c944449..4c67ae6 100644 --- a/Window.py +++ b/Window.py @@ -22,21 +22,7 @@ class Window: self.menubar.append(mi) # Projects Table - project_table = gtk.Table(rows = 2, columns = 9) - - new_project_combobox = gtk.combo_box_entry_new_text() - new_project_combobox.append_text("Project1") - new_project_combobox.append_text("Project2") - - col_headers = ('Project', - 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Tot') - for i in range(len(col_headers)): - l = gtk.Label() - l.set_markup('%s' % col_headers[i]) - l.set_size_request(35 if i > 0 else 200, -1) - project_table.attach(l, i, i + 1, 0, 1) - - project_table.attach(new_project_combobox, 0, 1, 1, 2) + self.updateProjects() # Bottom Control Bar self.mark_label = gtk.Label() @@ -52,12 +38,32 @@ class Window: vbox = gtk.VBox() vbox.pack_start(self.menubar) - vbox.pack_start(project_table) + vbox.pack_start(self.projects_table) vbox.pack_start(gtk.HSeparator()) vbox.pack_start(hbox) self.window.add(vbox) + def updateProjects(self): + self.projects = self.ds.getProjects() + self.projects_table = gtk.Table(rows = 2, columns = 9) + + new_project_combobox = gtk.combo_box_entry_new_text() + project_names = self.projects.values() + project_names.sort() + for project in project_names: + new_project_combobox.append_text(project) + + col_headers = ('Project', + 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Tot') + for i in range(len(col_headers)): + l = gtk.Label() + l.set_markup('%s' % col_headers[i]) + 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(new_project_combobox, 0, 1, 1, 2) + def main(self): self.window.show_all() gtk.main()