|
|
|
@ -6,7 +6,7 @@ class TextEntry: |
|
|
|
|
"""A part of a window that handles text entry. |
|
|
|
|
Properties: |
|
|
|
|
value holds the string that was entered |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Public Methods: |
|
|
|
|
set_geom(row,column,width) Sets the geometry in the window |
|
|
|
|
set_value(string) Set the value and redraw |
|
|
|
@ -53,7 +53,7 @@ class TextEntry: |
|
|
|
|
self.cursor = 0 |
|
|
|
|
self.start = 0 |
|
|
|
|
self.redraw() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_input(self,ch): |
|
|
|
|
if ch==curses.KEY_LEFT: |
|
|
|
|
self._mv_cursor(-1) |
|
|
|
@ -79,7 +79,7 @@ class TextEntry: |
|
|
|
|
# Private functions |
|
|
|
|
def _mv_cursor(self,delta): |
|
|
|
|
self._set_cursor(self.cursor + delta) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _set_cursor(self, new_c): |
|
|
|
|
self.cursor = max(0, min(len(self.value), new_c)) |
|
|
|
|
self.start = max(0,self.cursor-self.width+1) |
|
|
|
@ -109,7 +109,7 @@ class TextEntry: |
|
|
|
|
class FormWindow: |
|
|
|
|
|
|
|
|
|
"""General class for a Form Window. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To use, make the window for it, call the constructor, then call event_loop. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
@ -270,8 +270,8 @@ class FormWindow: |
|
|
|
|
if self.bt==-1: |
|
|
|
|
self.entries[self.hl].handle_input(ch) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BookForm(FormWindow): |
|
|
|
|
caption = "Add a Book" |
|
|
|
@ -279,13 +279,13 @@ class BookForm(FormWindow): |
|
|
|
|
labels = ["ISBN", "LCCN", "Title", "Subtitle", "Authors", "Edition", |
|
|
|
|
"Publisher", "Publish Date", "Publish Year", "Publish Month", "Publish location", |
|
|
|
|
"Pages", "Pagination", "Weight"] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# redefineable functions lookup is called when 'enter' is pressed on ISBN |
|
|
|
|
# and returns the looked-up book. Default returns nothing |
|
|
|
|
def lookup_isbn(self,isbn): |
|
|
|
|
return {'isbn':isbn} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def lookup_lccn(self,lccn): |
|
|
|
|
return {'lccn':lccn} |
|
|
|
|
|
|
|
|
|