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=bookData.openLibrary
89 bf.caption='Add a Book'
97 w=curses.newwin(1,50,10,10)
98 w.addstr("I will be used to update or modify book records")
102 (my,mx)=stdscr.getmaxyx()
103 w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
104 b = browser.trashBrowser(w,hb)
110 (my,mx)=stdscr.getmaxyx()
111 w=curses.newwin(20,80,(my-20)/2,(mx-80)/2)
112 b = browser.bookBrowser(w,hb)
118 (my,mx)=stdscr.getmaxyx()
119 w=curses.newwin(10,40,(my-10)/2,(mx-40)/2)
120 c = browser.categoryBrowser(w,hb)
121 c.refreshCategories()
122 c.sortByColumn('category')
127 m = [("Browse Library", browseMenu),
128 ("Add Book", addForm),
129 ("Categories", catMenu),
130 ("View Trash", trashMenu),
133 curses.wrapper(menutest, m)