added category viewer
This commit is contained in:
parent
2e3bf86930
commit
c1dfa009df
|
@ -105,11 +105,11 @@ class browserWindow:
|
||||||
ch = self.w.getch()
|
ch = self.w.getch()
|
||||||
|
|
||||||
def handleInput(self,ch):
|
def handleInput(self,ch):
|
||||||
if ch == curses.KEY_UP:
|
if ch == curses.KEY_UP or ch == 107 or ch == 16:
|
||||||
if self.hl == self.topline:
|
if self.hl == self.topline:
|
||||||
self.scroll(-self.pageSize/2-1)
|
self.scroll(-self.pageSize/2-1)
|
||||||
self.mvHighlight(-1)
|
self.mvHighlight(-1)
|
||||||
elif ch == curses.KEY_DOWN:
|
elif ch == curses.KEY_DOWN or ch == 106 or ch == 14:
|
||||||
if self.hl == self.topline+self.pageSize-1:
|
if self.hl == self.topline+self.pageSize-1:
|
||||||
self.scroll(+self.pageSize/2+1)
|
self.scroll(+self.pageSize/2+1)
|
||||||
self.mvHighlight(+1)
|
self.mvHighlight(+1)
|
||||||
|
@ -166,10 +166,11 @@ class bookBrowser(browserWindow):
|
||||||
self.viewSelection(book)
|
self.viewSelection(book)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
def categoryBrowser():
|
class categoryBrowser(browserWindow):
|
||||||
columnDefs = [('ID',0,3),
|
columnDefs = [('ID',0,3),
|
||||||
('Category',100,None)]
|
('Category',100,None)]
|
||||||
|
|
||||||
|
|
||||||
def refreshCategories(self):
|
def refreshCategories(self):
|
||||||
self.entries = []
|
self.entries = []
|
||||||
cats = db.getCategories()
|
cats = db.getCategories()
|
||||||
|
|
18
librarian.py
18
librarian.py
|
@ -40,14 +40,14 @@ def menu(w, items):
|
||||||
w.refresh()
|
w.refresh()
|
||||||
ch=w.getch()
|
ch=w.getch()
|
||||||
while (ch!=113 and ch!=27): # leave on q or ESC
|
while (ch!=113 and ch!=27): # leave on q or ESC
|
||||||
if ch==curses.KEY_UP:
|
if ch==curses.KEY_UP or ch==107 or ch==16:
|
||||||
if highlight!=0:
|
if highlight!=0:
|
||||||
w.chgat(highlight,0, 0)
|
w.chgat(highlight,0, 0)
|
||||||
highlight -= 1
|
highlight -= 1
|
||||||
while(items[highlight][0]==""):
|
while(items[highlight][0]==""):
|
||||||
highlight -=1
|
highlight -=1
|
||||||
w.chgat(highlight,0, curses.A_REVERSE)
|
w.chgat(highlight,0, curses.A_REVERSE)
|
||||||
if ch==curses.KEY_DOWN:
|
if ch==curses.KEY_DOWN or ch==106 or ch==14:
|
||||||
if highlight!=len(items)-1:
|
if highlight!=len(items)-1:
|
||||||
w.chgat(highlight,0, 0)
|
w.chgat(highlight,0, 0)
|
||||||
highlight += 1
|
highlight += 1
|
||||||
|
@ -94,7 +94,6 @@ def addForm():
|
||||||
if len(book)!=0:
|
if len(book)!=0:
|
||||||
db.addBook(book)
|
db.addBook(book)
|
||||||
|
|
||||||
|
|
||||||
def updateMenu():
|
def updateMenu():
|
||||||
w=curses.newwin(1,50,10,10)
|
w=curses.newwin(1,50,10,10)
|
||||||
w.addstr("I will be used to update or modify book records")
|
w.addstr("I will be used to update or modify book records")
|
||||||
|
@ -109,6 +108,17 @@ def browseMenu():
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
|
w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
|
||||||
b = browser.bookBrowser(w)
|
b = browser.bookBrowser(w)
|
||||||
|
b.refreshBooks()
|
||||||
|
hb.commands=browser_commands
|
||||||
|
hb.refresh()
|
||||||
|
b.eventLoop()
|
||||||
|
b.clear()
|
||||||
|
|
||||||
|
def catMenu():
|
||||||
|
(my,mx)=stdscr.getmaxyx()
|
||||||
|
w=curses.newwin(10,40,(my-10)/2,(mx-40)/2)
|
||||||
|
b = browser.categoryBrowser(w)
|
||||||
|
b.refreshCategories()
|
||||||
hb.commands=browser_commands
|
hb.commands=browser_commands
|
||||||
hb.refresh()
|
hb.refresh()
|
||||||
b.eventLoop()
|
b.eventLoop()
|
||||||
|
@ -117,7 +127,7 @@ def browseMenu():
|
||||||
|
|
||||||
m = [("Browse Library", browseMenu),
|
m = [("Browse Library", browseMenu),
|
||||||
("Add Book or other item", addForm),
|
("Add Book or other item", addForm),
|
||||||
("Modify/Update record", updateMenu),
|
("View the categories", catMenu),
|
||||||
("Remove book from catalogue", deleteMenu),
|
("Remove book from catalogue", deleteMenu),
|
||||||
("",exit),
|
("",exit),
|
||||||
("Exit", exit)]
|
("Exit", exit)]
|
||||||
|
|
Loading…
Reference in New Issue