|
@@ -80,13 +80,7 @@ def records(cursor, col_idx_map):
|
|
|
|
|
|
def record_matches(record, strict=None, **kwargs):
|
|
def record_matches(record, strict=None, **kwargs):
|
|
strict = strict or []
|
|
strict = strict or []
|
|
- if kwargs['product']:
|
|
|
|
- with open('log', 'a') as f:
|
|
|
|
- f.write(f"Filter {strict}: {kwargs}\n")
|
|
|
|
-
|
|
|
|
for k,v in kwargs.items():
|
|
for k,v in kwargs.items():
|
|
- with open('log', 'a') as f:
|
|
|
|
- f.write(f"Record: {record}\n")
|
|
|
|
if not v:
|
|
if not v:
|
|
continue
|
|
continue
|
|
|
|
|
|
@@ -94,12 +88,8 @@ def record_matches(record, strict=None, **kwargs):
|
|
return False
|
|
return False
|
|
|
|
|
|
if v.lower() not in record[k].lower():
|
|
if v.lower() not in record[k].lower():
|
|
- with open('log', 'a') as f:
|
|
|
|
- f.write(f"No match\n")
|
|
|
|
return False
|
|
return False
|
|
|
|
|
|
- with open('log', 'a') as f:
|
|
|
|
- f.write(f"Match\n")
|
|
|
|
return True
|
|
return True
|
|
|
|
|
|
def unique_suggestions(name, exclude=NON_IDENTIFIER_COLUMNS, **kwargs):
|
|
def unique_suggestions(name, exclude=NON_IDENTIFIER_COLUMNS, **kwargs):
|
|
@@ -116,7 +106,7 @@ def show_or_exit(key):
|
|
if isinstance(key, tuple):
|
|
if isinstance(key, tuple):
|
|
return
|
|
return
|
|
|
|
|
|
- if key in ('esc'):
|
|
|
|
|
|
+ if key in ('esc',):
|
|
raise urwid.ExitMainLoop()
|
|
raise urwid.ExitMainLoop()
|
|
|
|
|
|
def interleave(_list, div):
|
|
def interleave(_list, div):
|
|
@@ -163,7 +153,7 @@ class AutoCompleteFloatEdit(numedit.FloatEdit):
|
|
|
|
|
|
def update_caption(self):
|
|
def update_caption(self):
|
|
if self.pallete is not None:
|
|
if self.pallete is not None:
|
|
- self.set_caption((self.pallete, f'{self.op}'))
|
|
|
|
|
|
+ self.set_caption((self.pallete, f'{self.op} '))
|
|
else:
|
|
else:
|
|
self.set_caption(f'{self.op} ')
|
|
self.set_caption(f'{self.op} ')
|
|
|
|
|
|
@@ -206,17 +196,34 @@ class AutoCompleteFloatEdit(numedit.FloatEdit):
|
|
elif key in ('=', 'enter',):
|
|
elif key in ('=', 'enter',):
|
|
self.calc()
|
|
self.calc()
|
|
return
|
|
return
|
|
- elif key in ('esc', 'left', 'right', 'up', 'down', 'backspace', 'delete',) or \
|
|
|
|
- key in '0123456789.':
|
|
|
|
- return super(AutoCompleteFloatEdit, self).keypress(size, key)
|
|
|
|
|
|
+ #elif key in ('esc', 'left', 'right', 'up', 'down', 'backspace', 'delete',) or \
|
|
|
|
+ # key in '0123456789.':
|
|
|
|
+ return super(AutoCompleteFloatEdit, self).keypress(size, key)
|
|
|
|
+
|
|
|
|
+class NoTabCheckBox(urwid.CheckBox):
|
|
|
|
+ def keypress(self, size, key):
|
|
|
|
+ if not isinstance(key, tuple) and key == 'tab':
|
|
|
|
+ return
|
|
else:
|
|
else:
|
|
- return
|
|
|
|
|
|
+ return super(NoTabCheckBox, self).keypress(size, key)
|
|
|
|
|
|
|
|
+def _set_focus_path(container, path):
|
|
|
|
+ try:
|
|
|
|
+ container.set_focus_path(path)
|
|
|
|
+ return
|
|
|
|
+ except IndexError:
|
|
|
|
+ pass
|
|
|
|
+
|
|
|
|
+ if path[-1] == 0 and len(path) > 1:
|
|
|
|
+ _set_focus_path(container, path[:-1])
|
|
|
|
+ return
|
|
|
|
+
|
|
|
|
+ raise IndexError
|
|
|
|
|
|
class GroceryTransactionEditor(urwid.WidgetPlaceholder):
|
|
class GroceryTransactionEditor(urwid.WidgetPlaceholder):
|
|
def __init__(self, fields):
|
|
def __init__(self, fields):
|
|
super(GroceryTransactionEditor, self).__init__(urwid.SolidFill(u'/'))
|
|
super(GroceryTransactionEditor, self).__init__(urwid.SolidFill(u'/'))
|
|
- self.organic_checkbox = urwid.CheckBox(
|
|
|
|
|
|
+ self.organic_checkbox = NoTabCheckBox(
|
|
u"Organic",
|
|
u"Organic",
|
|
on_state_change=self.apply_organic_state
|
|
on_state_change=self.apply_organic_state
|
|
)
|
|
)
|
|
@@ -224,15 +231,32 @@ class GroceryTransactionEditor(urwid.WidgetPlaceholder):
|
|
self.widgets = dict()
|
|
self.widgets = dict()
|
|
self.show('transaction')
|
|
self.show('transaction')
|
|
|
|
|
|
|
|
+ def advance_focus(self):
|
|
|
|
+ container = self.original_widget.original_widget.original_widget
|
|
|
|
+ path = container.get_focus_path()
|
|
|
|
+ for idx, part in [ i for i in enumerate(path)][::-1]:
|
|
|
|
+ p = [ i for i in path ]
|
|
|
|
+ p[idx] += 1
|
|
|
|
+ try:
|
|
|
|
+ _set_focus_path(container, p)
|
|
|
|
+ if path == [3]:
|
|
|
|
+ self.advance_focus()
|
|
|
|
+ return
|
|
|
|
+ except IndexError:
|
|
|
|
+ path[idx] = 0
|
|
|
|
+
|
|
|
|
+ container.set_focus_path([2,0,0,0])
|
|
|
|
+
|
|
|
|
+
|
|
def keypress(self, size, key):
|
|
def keypress(self, size, key):
|
|
if isinstance(key, tuple):
|
|
if isinstance(key, tuple):
|
|
return
|
|
return
|
|
|
|
|
|
if key == 'tab':
|
|
if key == 'tab':
|
|
- # need to change this to self.advance_focus
|
|
|
|
- return super(GroceryTransactionEditor, self).keypress(size, 'enter')
|
|
|
|
- else:
|
|
|
|
|
|
+ self.advance_focus()
|
|
|
|
+ else: #if key == 'esc':
|
|
return super(GroceryTransactionEditor, self).keypress(size, key)
|
|
return super(GroceryTransactionEditor, self).keypress(size, key)
|
|
|
|
+
|
|
|
|
|
|
def _init_data(self, fields):
|
|
def _init_data(self, fields):
|
|
self.data = OrderedDict([
|
|
self.data = OrderedDict([
|
|
@@ -379,7 +403,7 @@ class GroceryTransactionEditor(urwid.WidgetPlaceholder):
|
|
fields[r] if r is not None else urwid.Divider() for r in side_pane
|
|
fields[r] if r is not None else urwid.Divider() for r in side_pane
|
|
]))
|
|
]))
|
|
main_pane_widgets = []
|
|
main_pane_widgets = []
|
|
- for r in grid_layout:
|
|
|
|
|
|
+ for i, r in enumerate(grid_layout):
|
|
widgets = []
|
|
widgets = []
|
|
for c in r:
|
|
for c in r:
|
|
if c is not None:
|
|
if c is not None:
|
|
@@ -391,6 +415,7 @@ class GroceryTransactionEditor(urwid.WidgetPlaceholder):
|
|
widgets.append(urwid.Divider())
|
|
widgets.append(urwid.Divider())
|
|
main_pane_widgets.append(urwid.Columns(widgets))
|
|
main_pane_widgets.append(urwid.Columns(widgets))
|
|
|
|
|
|
|
|
+
|
|
main_pane_widget = urwid.Pile(main_pane_widgets)
|
|
main_pane_widget = urwid.Pile(main_pane_widgets)
|
|
|
|
|
|
widget = urwid.Pile([
|
|
widget = urwid.Pile([
|