15 menu_commands = [(' q','quit')]
22 (rows,cols)=stdscr.getmaxyx()
23 bar = curses.newwin(1,cols-2,rows-1,1)
24 hb = helpBar.helpBar(bar)
25 hb.command=menu_commands
27 w = curses.newwin(10,40,(rows-10)/2, (cols-40)/2)
33 # item is a list of (string, callable) tuples
37 redrawMenu(w,items,highlight)
41 while (ch!=113 and ch!=27): # leave on q or ESC
42 if ch==curses.KEY_UP or ch==107 or ch==16:
44 w.chgat(highlight,0, 0)
46 while(items[highlight][0]==""):
48 w.chgat(highlight,0, curses.A_REVERSE)
49 if ch==curses.KEY_DOWN or ch==106 or ch==14:
50 if highlight!=len(items)-1:
51 w.chgat(highlight,0, 0)
53 while(items[highlight][0]==""):
55 w.chgat(highlight,0, curses.A_REVERSE)
56 if ch==curses.KEY_PPAGE:
57 w.chgat(highlight,0, 0)
59 w.chgat(highlight,0, curses.A_REVERSE)
60 if ch==curses.KEY_NPAGE:
61 w.chgat(highlight,0, 0)
62 highlight = len(items)-1
63 w.chgat(highlight,0, curses.A_REVERSE)
65 (s,f)=items[highlight]
67 redrawMenu(w,items,highlight)
71 def redrawMenu(w,items,highlight):
73 for (mitem,fun) in items:
76 w.chgat(highlight, 0, curses.A_REVERSE)
78 hb.commands=menu_commands
84 (my,mx)=stdscr.getmaxyx()
85 bf = form.bookForm(w,hb)
87 w.mvwin((my-r)/2,(mx-c)/2)
88 bf.lookup_isbn=bookData.openLibrary_isbn
89 bf.lookup_lccn=bookData.openLibrary_lccn
90 bf.caption='Add a Book'
98 w=curses.newwin(1,50,10,10)
99 w.addstr("I will be used to update or modify book records")
103 (my,mx)=stdscr.getmaxyx()
104 w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
105 b = browser.trashBrowser(w,hb)
111 (my,mx)=stdscr.getmaxyx()
112 w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
113 b = browser.bookBrowser(w,hb)
119 (my,mx)=stdscr.getmaxyx()
120 w=curses.newwin(10,40,(my-10)/2,(mx-40)/2)
121 c = browser.categoryBrowser(w,hb)
122 c.refreshCategories()
123 c.sortByColumn('category')
128 m = [("Browse Library", browseMenu),
129 ("Add Book", addForm),
130 ("Categories", catMenu),
131 ("View Trash", trashMenu),
134 curses.wrapper(menutest, m)