|
@@ -39,21 +39,21 @@ class TransactionEditor(FocusWidget):
|
|
|
def keypress(self, size, key):
|
|
|
if isinstance(key, tuple):
|
|
|
return
|
|
|
-
|
|
|
+
|
|
|
if getattr(self._w.original_widget, 'original_widget', None) is None:
|
|
|
return super().keypress(size, key)
|
|
|
-
|
|
|
+
|
|
|
if key == 'tab':
|
|
|
self.advance_focus()
|
|
|
elif key == 'shift tab':
|
|
|
self.advance_focus(reverse=True)
|
|
|
elif key == 'ctrl delete':
|
|
|
self.clear()
|
|
|
- self.focus_on_product()
|
|
|
+ self.focus_on(self.edit_fields['product'])
|
|
|
elif key == 'insert':
|
|
|
self.save_and_clear_cb()
|
|
|
elif key == 'ctrl p':
|
|
|
- self.focus_on_product()
|
|
|
+ self.focus_on(self.edit_fields['product'])
|
|
|
else:
|
|
|
return super().keypress(size, key)
|
|
|
|
|
@@ -103,7 +103,7 @@ class TransactionEditor(FocusWidget):
|
|
|
tf.set_text('')
|
|
|
self.graph.set_data([],0)
|
|
|
return self.update()
|
|
|
-
|
|
|
+
|
|
|
def update(self):
|
|
|
data = self.data
|
|
|
date, store = data['ts'], data['store']
|
|
@@ -137,9 +137,9 @@ class TransactionEditor(FocusWidget):
|
|
|
if df.empty:
|
|
|
self.rating.update_rating(None, None, None, unit)
|
|
|
return
|
|
|
-
|
|
|
+
|
|
|
assert len(df['avg'].unique()) == 1, f"There should be only one average price: {df['avg'].unique()}"
|
|
|
-
|
|
|
+
|
|
|
# all time (or all data) avg(mean), min, max
|
|
|
_avg, _min, _max = [
|
|
|
float(x) for x in df[['avg','min','max']].iloc[0]
|
|
@@ -181,9 +181,10 @@ class TransactionEditor(FocusWidget):
|
|
|
|
|
|
|
|
|
|
|
|
- def focus_on_product(self):
|
|
|
+ def focus_on(self, w):
|
|
|
+ _, p = next(filter(lambda x: x[0] is w, self.iter_focus_paths()))
|
|
|
path = self.container.get_focus_path()
|
|
|
- while path != [2,0,1,0,0]:
|
|
|
+ while path != p:
|
|
|
self.advance_focus()
|
|
|
path = self.container.get_focus_path()
|
|
|
|
|
@@ -267,7 +268,7 @@ class TransactionEditor(FocusWidget):
|
|
|
for (k, ef) in self.edit_fields.items():
|
|
|
connect_signal(ef, 'postchange', lambda _,v: self.update())
|
|
|
connect_signal(ef, 'apply', lambda w, name: autocomplete_cb(w, name, self.data))
|
|
|
-
|
|
|
+
|
|
|
_widgets.update(dict([
|
|
|
(k, LineBox(
|
|
|
AttrMap(AutoCompletePopUp(
|
|
@@ -309,7 +310,7 @@ class TransactionEditor(FocusWidget):
|
|
|
})
|
|
|
connect_signal(self.buttons['done'], 'click', lambda _: save_and_clear_cb())
|
|
|
connect_signal(self.buttons['clear'], 'click', lambda _: self.clear())
|
|
|
-
|
|
|
+
|
|
|
banner = Pile([
|
|
|
Padding(header, 'center', width=('relative', 100)),
|
|
|
Padding(_copyright, 'center', width=('relative', 100)),
|
|
@@ -325,7 +326,7 @@ class TransactionEditor(FocusWidget):
|
|
|
self.organic_checkbox
|
|
|
], dividechars=2), title='Product', title_align='left')
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
components['side_pane'] = (12, Pile([
|
|
|
_widgets[r] if r is not None else Divider() for r in side_pane
|
|
|
]))
|
|
@@ -342,7 +343,7 @@ class TransactionEditor(FocusWidget):
|
|
|
components['main_pane'].append(Columns(col))
|
|
|
|
|
|
components['main_pane'] = Pile(components['main_pane'])
|
|
|
-
|
|
|
+
|
|
|
widget = Pile([
|
|
|
banner,
|
|
|
Divider(),
|
|
@@ -353,7 +354,7 @@ class TransactionEditor(FocusWidget):
|
|
|
Divider(),
|
|
|
components['bottom_button_bar']
|
|
|
])
|
|
|
- widget = Filler(widget, 'top')
|
|
|
+ widget = Filler(widget, 'top')
|
|
|
widget = AttrMap(widget, 'bg')
|
|
|
super().__init__(widget, map(
|
|
|
lambda x: next(w[1] for w in chain(
|