started on category browser
authorJohn Ladan <jladan@uwaterloo.ca>
Thu, 22 Mar 2012 21:28:06 +0000 (17:28 -0400)
committerJohn Ladan <jladan@uwaterloo.ca>
Thu, 22 Mar 2012 21:28:06 +0000 (17:28 -0400)
browser.py

index 2e3d1c8..da70bfe 100644 (file)
@@ -7,10 +7,7 @@ class browserWindow:
     entries = []
     topline = 0
     # column definitions are in (label, weight, specified width) triples
-    columnDefs = [('ID',0,3),
-                  ('ISBN',0,13),
-                  ('Authors',30,None),
-                  ('Title',60,None)]
+    columnDefs = [('something',1,None)]
     mx = my = 0
 
 
@@ -21,7 +18,6 @@ class browserWindow:
     def __init__(self,window):
         self.w = window
         self.updateGeometry()
-        self.refreshBooks()
 
     def sortByColumn(self, col):
         self.entries.sort() # key=dict.get(col))
@@ -127,6 +123,10 @@ class browserWindow:
 
 
 class bookBrowser(browserWindow):
+    columnDefs = [('ID',0,3),
+                  ('ISBN',0,13),
+                  ('Authors',30,None),
+                  ('Title',60,None)]
     # redefinable functions
     def updateSelection(self,book):
         bookid = book['id']
@@ -166,3 +166,16 @@ class bookBrowser(browserWindow):
             self.viewSelection(book)
             self.refresh()
 
+def categoryBrowser():
+    columnDefs = [('ID',0,3),
+                  ('Category',100,None)]
+
+    def refreshCategories(self):
+        self.entries = []
+        cats = db.getCategories()
+        for c in cats:
+            self.entries.append({'category':c})
+
+    def handleInput(self,ch):
+        browserWindow.handleInput(self,ch)
+