Made sizes of windows better, and easier to change
This commit is contained in:
parent
18058ac98c
commit
1324e07bc5
34
browser.py
34
browser.py
|
@ -14,14 +14,14 @@ class browserWindow:
|
||||||
# column definitions are in (label, weight, specified width) triples
|
# column definitions are in (label, weight, specified width) triples
|
||||||
columnDefs = [('something',1,None)]
|
columnDefs = [('something',1,None)]
|
||||||
mx = my = 0
|
mx = my = 0
|
||||||
cx = cy = 0
|
|
||||||
# for searches
|
# for searches
|
||||||
last_search = ""
|
last_search = ""
|
||||||
found_index = 0
|
found_index = 0
|
||||||
|
|
||||||
def __init__(self,window,helpbar):
|
def __init__(self,window,helpbar, height=50, width=80):
|
||||||
self.w = window
|
self.w = window
|
||||||
self.hb = helpbar
|
self.hb = helpbar
|
||||||
|
self.w.resize(height,width)
|
||||||
self.updateGeometry()
|
self.updateGeometry()
|
||||||
self.commands = self.cs+self.commands
|
self.commands = self.cs+self.commands
|
||||||
|
|
||||||
|
@ -32,9 +32,6 @@ class browserWindow:
|
||||||
|
|
||||||
def updateGeometry(self):
|
def updateGeometry(self):
|
||||||
(self.my,self.mx)=self.w.getmaxyx()
|
(self.my,self.mx)=self.w.getmaxyx()
|
||||||
(y,x) = self.w.getbegyx()
|
|
||||||
self.cx = x + self.mx//2
|
|
||||||
self.cy = y + self.my//2
|
|
||||||
self.pageSize = self.my-4
|
self.pageSize = self.my-4
|
||||||
self.calcColWidths()
|
self.calcColWidths()
|
||||||
|
|
||||||
|
@ -70,8 +67,9 @@ class browserWindow:
|
||||||
self.w.refresh()
|
self.w.refresh()
|
||||||
|
|
||||||
def centreChild(self,child):
|
def centreChild(self,child):
|
||||||
(y,x)=child.getmaxyx()
|
(y,x) = self.w.getbegyx()
|
||||||
child.mvwin(self.cy-y//2,self.cx-x//2)
|
(r,c) = child.getmaxyx()
|
||||||
|
child.mvwin( y+(self.my-r)//2,x+(self.mx-c)//2)
|
||||||
|
|
||||||
|
|
||||||
def displayHeader(self):
|
def displayHeader(self):
|
||||||
|
@ -238,8 +236,8 @@ class browserWindow:
|
||||||
else:
|
else:
|
||||||
self.hb.display(self.last_search+' not found')
|
self.hb.display(self.last_search+' not found')
|
||||||
elif ch == 270: # F6 Sorts
|
elif ch == 270: # F6 Sorts
|
||||||
w = curses.newwin(40,20,20,20)
|
w = curses.newwin(1,1)
|
||||||
cl = columnSelector(w,self.hb)
|
cl = columnSelector(w,self.hb,40,20)
|
||||||
self.centreChild(w)
|
self.centreChild(w)
|
||||||
col = cl.eventLoop()
|
col = cl.eventLoop()
|
||||||
cl.clear()
|
cl.clear()
|
||||||
|
@ -265,8 +263,8 @@ class trashBrowser(browserWindow):
|
||||||
# redefinable functions
|
# redefinable functions
|
||||||
def viewSelection(self,book):
|
def viewSelection(self,book):
|
||||||
bookid = book['id']
|
bookid = book['id']
|
||||||
w=curses.newwin(1,1,20,20)
|
w=curses.newwin(1,1)
|
||||||
bf = BookForm(w,self.hb,book)
|
bf = BookForm(w, self.hb, book, width=self.mx-10)
|
||||||
self.centreChild(w)
|
self.centreChild(w)
|
||||||
bf.caption='Viewing Book '+str(bookid)
|
bf.caption='Viewing Book '+str(bookid)
|
||||||
bf.blabel='done'
|
bf.blabel='done'
|
||||||
|
@ -332,7 +330,7 @@ class bookBrowser(browserWindow):
|
||||||
bookid = book['id']
|
bookid = book['id']
|
||||||
|
|
||||||
w=curses.newwin(1,1)
|
w=curses.newwin(1,1)
|
||||||
bf=BookForm(w,self.hb,book)
|
bf = BookForm(w,self.hb,book, width=self.mx-20)
|
||||||
self.centreChild(w)
|
self.centreChild(w)
|
||||||
bf.caption='Update Book '+str(bookid)
|
bf.caption='Update Book '+str(bookid)
|
||||||
bf.blabel='update'
|
bf.blabel='update'
|
||||||
|
@ -343,8 +341,8 @@ class bookBrowser(browserWindow):
|
||||||
|
|
||||||
def viewSelection(self,book):
|
def viewSelection(self,book):
|
||||||
bookid = book['id']
|
bookid = book['id']
|
||||||
w=curses.newwin(1,1,20,20)
|
w=curses.newwin(1,1)
|
||||||
bf = BookForm(w,self.hb,book)
|
bf = BookForm(w,self.hb,book, width=self.mx-20)
|
||||||
self.centreChild(w)
|
self.centreChild(w)
|
||||||
bf.caption='Viewing Book '+str(bookid)
|
bf.caption='Viewing Book '+str(bookid)
|
||||||
bf.blabel='done'
|
bf.blabel='done'
|
||||||
|
@ -352,8 +350,8 @@ class bookBrowser(browserWindow):
|
||||||
bf.clear()
|
bf.clear()
|
||||||
|
|
||||||
def categorizeSelection(self,book):
|
def categorizeSelection(self,book):
|
||||||
w = curses.newwin(40,20,20,20)
|
w = curses.newwin(1,1)
|
||||||
cs = categorySelector(w,self.hb)
|
cs = categorySelector(w,self.hb,40,40)
|
||||||
self.centreChild(w)
|
self.centreChild(w)
|
||||||
cs.book = book
|
cs.book = book
|
||||||
cs.refreshCategories()
|
cs.refreshCategories()
|
||||||
|
@ -530,10 +528,10 @@ class columnSelector(browserWindow):
|
||||||
{'column': 'publish location'}, {'column': 'pages'}, {'column': 'pagination'},
|
{'column': 'publish location'}, {'column': 'pages'}, {'column': 'pagination'},
|
||||||
{'column': 'weight'}, {'column': 'last updated'}]
|
{'column': 'weight'}, {'column': 'last updated'}]
|
||||||
|
|
||||||
def __init__(self,window,helpbar):
|
def __init__(self,window,helpbar,height=40,width=20):
|
||||||
self.selected = [False,False,False,False,False,False,False,
|
self.selected = [False,False,False,False,False,False,False,
|
||||||
False,False,False,False,False,False,False,False]
|
False,False,False,False,False,False,False,False]
|
||||||
browserWindow.__init__(self,window,helpbar)
|
browserWindow.__init__(self,window,helpbar,height,width)
|
||||||
|
|
||||||
|
|
||||||
def eventLoop(self):
|
def eventLoop(self):
|
||||||
|
|
4
form.py
4
form.py
|
@ -130,9 +130,9 @@ class FormWindow:
|
||||||
|
|
||||||
|
|
||||||
# Public functions
|
# Public functions
|
||||||
def __init__(self,window,helpbar,book={}):
|
def __init__(self,window,helpbar,book={}, width=50):
|
||||||
self.w = window
|
self.w = window
|
||||||
self.w.resize(len(self.labels)+6,50)
|
self.w.resize(len(self.labels)+6,width)
|
||||||
self.hb = helpbar
|
self.hb = helpbar
|
||||||
self._make_entries()
|
self._make_entries()
|
||||||
self._update_geometry()
|
self._update_geometry()
|
||||||
|
|
30
librarian.py
30
librarian.py
|
@ -82,7 +82,7 @@ def redrawMenu(w,items,highlight):
|
||||||
def addForm():
|
def addForm():
|
||||||
w=curses.newwin(1,1)
|
w=curses.newwin(1,1)
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
bf = form.BookForm(w,hb)
|
bf = form.BookForm(w,hb,width=mx-20)
|
||||||
(r,c)=w.getmaxyx()
|
(r,c)=w.getmaxyx()
|
||||||
w.mvwin((my-r)//2,(mx-c)//2)
|
w.mvwin((my-r)//2,(mx-c)//2)
|
||||||
bf.lookup_isbn=book_data.openLibrary_isbn
|
bf.lookup_isbn=book_data.openLibrary_isbn
|
||||||
|
@ -101,28 +101,34 @@ def updateMenu():
|
||||||
|
|
||||||
def trashMenu():
|
def trashMenu():
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
w=curses.newwin(20,80,(my-20)//2,(mx-80)//2)
|
w=curses.newwin(3,5)
|
||||||
b = browser.trashBrowser(w,hb)
|
b = browser.trashBrowser(w,hb,my-10,mx-10)
|
||||||
|
(r,c) = w.getmaxyx()
|
||||||
|
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
||||||
b.refreshBooks()
|
b.refreshBooks()
|
||||||
b.eventLoop()
|
b.eventLoop()
|
||||||
b.clear()
|
b.clear()
|
||||||
|
|
||||||
def browseMenu():
|
def browseMenu():
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
w=curses.newwin(20,80,(my-20)//2,(mx-80)//2)
|
w=curses.newwin(3,5)
|
||||||
b = browser.bookBrowser(w,hb)
|
b = browser.bookBrowser(w,hb, my-10, mx-10)
|
||||||
|
(r,c) = w.getmaxyx()
|
||||||
|
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
||||||
b.refreshBooks()
|
b.refreshBooks()
|
||||||
b.eventLoop()
|
b.eventLoop()
|
||||||
b.clear()
|
b.clear()
|
||||||
|
|
||||||
def catMenu():
|
def catMenu():
|
||||||
(my,mx)=stdscr.getmaxyx()
|
(my,mx)=stdscr.getmaxyx()
|
||||||
w=curses.newwin(10,40,(my-10)//2,(mx-40)//2)
|
w=curses.newwin(3,5)
|
||||||
c = browser.categoryBrowser(w,hb)
|
cat = browser.categoryBrowser(w,hb, 10,40)
|
||||||
c.refreshCategories()
|
(r,c) = w.getmaxyx()
|
||||||
c.sortByColumn('category')
|
w.mvwin((my-r)//2 -2, (mx-c)//2)
|
||||||
c.eventLoop()
|
cat.refreshCategories()
|
||||||
c.clear()
|
cat.sortByColumn('category')
|
||||||
|
cat.eventLoop()
|
||||||
|
cat.clear()
|
||||||
|
|
||||||
|
|
||||||
m = [("Browse Library", browseMenu),
|
m = [("Browse Library", browseMenu),
|
||||||
|
@ -132,3 +138,5 @@ m = [("Browse Library", browseMenu),
|
||||||
("",exit),
|
("",exit),
|
||||||
("Exit", exit)]
|
("Exit", exit)]
|
||||||
curses.wrapper(menutest, m)
|
curses.wrapper(menutest, m)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue