|
@@ -85,11 +85,11 @@ class TransactionEditor(FocusWidget):
|
|
|
|
|
|
@data.setter
|
|
|
def data(self, _data: dict):
|
|
|
- for k,v in _data.items():
|
|
|
- if k in self.edit_fields and v != self.edit_fields[k].get_edit_text():
|
|
|
- self.edit_fields[k].set_edit_text(v)
|
|
|
- if k in self.checkboxes and v != self.checkboxes[k].state:
|
|
|
- self.checkboxes[k].set_state(v)
|
|
|
+ for k,v in _data.items():
|
|
|
+ if k in self.edit_fields and v != self.edit_fields[k].get_edit_text():
|
|
|
+ self.edit_fields[k].set_edit_text(v)
|
|
|
+ if k in self.checkboxes and v != self.checkboxes[k].state:
|
|
|
+ self.checkboxes[k].set_state(v)
|
|
|
|
|
|
def clear(self):
|
|
|
for (k, ef) in self.edit_fields.items():
|
|
@@ -114,7 +114,7 @@ class TransactionEditor(FocusWidget):
|
|
|
)
|
|
|
self.update_historic_prices(data)
|
|
|
return self
|
|
|
-
|
|
|
+
|
|
|
def update_graph(self, df):
|
|
|
# after truncating, need to recalculate avg(median), min, max
|
|
|
df = df.sort_values(
|
|
@@ -176,7 +176,7 @@ class TransactionEditor(FocusWidget):
|
|
|
|
|
|
# all time (or all data) avg(mean), min, max
|
|
|
_avg, _min, _max = [
|
|
|
- float(x) for x in df[['avg','min','max']].iloc[0]
|
|
|
+ float(x) for x in df[['avg','min','max']].iloc[0]
|
|
|
]
|
|
|
self.rating.update_rating(_avg, _min, _max, unit, price=price, quantity=quantity)
|
|
|
self.update_graph(df)
|
|
@@ -197,18 +197,18 @@ class TransactionEditor(FocusWidget):
|
|
|
'clear': Button(('streak', u'Clear')),
|
|
|
}
|
|
|
self.edit_fields = {
|
|
|
- 'ts': AutoCompleteEdit(('bg', 'ts')),
|
|
|
- 'store': AutoCompleteEdit(('bg', 'store')),
|
|
|
- 'product': AutoCompleteEdit(('bg', 'product')),
|
|
|
- 'category': AutoCompleteEdit(('bg', 'category')),
|
|
|
- 'group': AutoCompleteEdit(('bg', 'group')),
|
|
|
- 'description': AutoCompleteEdit(('bg', 'description')),
|
|
|
- 'unit': AutoCompleteEdit(('bg', 'unit')),
|
|
|
- 'quantity': AutoCompleteFloatEdit(('bg', 'quantity')),
|
|
|
- 'price': AutoCompleteFloatEdit(('bg', 'price')),
|
|
|
+ 'ts': AutoCompleteEdit(('bg', 'ts')),
|
|
|
+ 'store': AutoCompleteEdit(('bg', 'store')),
|
|
|
+ 'product': AutoCompleteEdit(('bg', 'product')),
|
|
|
+ 'category': AutoCompleteEdit(('bg', 'category')),
|
|
|
+ 'group': AutoCompleteEdit(('bg', 'group')),
|
|
|
+ 'description': AutoCompleteEdit(('bg', 'description')),
|
|
|
+ 'unit': AutoCompleteEdit(('bg', 'unit')),
|
|
|
+ 'quantity': AutoCompleteFloatEdit(('bg', 'quantity')),
|
|
|
+ 'price': AutoCompleteFloatEdit(('bg', 'price')),
|
|
|
}
|
|
|
self.checkboxes = {
|
|
|
- 'organic': NoTabCheckBox(('bg', "Organic"), state='mixed'),
|
|
|
+ 'organic': NoTabCheckBox(('bg', "Organic"), state='mixed'),
|
|
|
}
|
|
|
self.text_fields = {
|
|
|
'dbview': Text(''),
|
|
@@ -222,15 +222,15 @@ class TransactionEditor(FocusWidget):
|
|
|
hatt=['dark red', 'dark red', 'dark red']
|
|
|
)
|
|
|
self.rating = Rating(dict(filter(
|
|
|
- lambda x: x[0] in ('spread','rating','marker'),
|
|
|
- self.text_fields.items()
|
|
|
+ lambda x: x[0] in ('spread','rating','marker'),
|
|
|
+ self.text_fields.items()
|
|
|
)))
|
|
|
self.organic_checkbox = self.checkboxes['organic']
|
|
|
connect_signal(self.organic_checkbox, 'postchange', lambda _,v: self.update())
|
|
|
layout = [
|
|
|
- [ 'ts', 'store', ],
|
|
|
- [ 'organic', 'product', ],
|
|
|
- [ 'category', 'group', ],
|
|
|
+ [ 'ts', 'store', ],
|
|
|
+ [ 'organic', 'product', ],
|
|
|
+ [ 'category', 'group', ],
|
|
|
]
|
|
|
side_pane = [
|
|
|
'unit',
|
|
@@ -276,31 +276,31 @@ class TransactionEditor(FocusWidget):
|
|
|
_copyright = Text(COPYRIGHT, 'center')
|
|
|
|
|
|
components = {
|
|
|
- 'bottom_button_bar': Columns(
|
|
|
+ 'bottom_button_bar': Columns(
|
|
|
[(8, self.buttons['done']), Divider(), (9, self.buttons['clear'])]
|
|
|
),
|
|
|
- 'badge': Pile(map(
|
|
|
- lambda x: _widgets[x] if x is not None else Divider,
|
|
|
- badge
|
|
|
- )),
|
|
|
+ 'badge': Pile(map(
|
|
|
+ lambda x: _widgets[x] if x is not None else Divider,
|
|
|
+ badge
|
|
|
+ )),
|
|
|
}
|
|
|
components.update({
|
|
|
- 'bottom_pane': Columns([
|
|
|
- Pile(map(
|
|
|
- lambda x: _widgets[x] if x is not None else Divider(),
|
|
|
- bottom_pane
|
|
|
- )),
|
|
|
- (self.graph.total_width+2, Pile([
|
|
|
- LineBox(
|
|
|
- AttrMap(components['badge'], 'badge'),
|
|
|
- title="Current Price", title_align='left',
|
|
|
- ),
|
|
|
- LineBox(
|
|
|
- self.graph,
|
|
|
- title="Historic Price", title_align='left'
|
|
|
- ),
|
|
|
- ])),
|
|
|
- ])
|
|
|
+ 'bottom_pane': Columns([
|
|
|
+ Pile(map(
|
|
|
+ lambda x: _widgets[x] if x is not None else Divider(),
|
|
|
+ bottom_pane
|
|
|
+ )),
|
|
|
+ (self.graph.total_width+2, Pile([
|
|
|
+ LineBox(
|
|
|
+ AttrMap(components['badge'], 'badge'),
|
|
|
+ title="Current Price", title_align='left',
|
|
|
+ ),
|
|
|
+ LineBox(
|
|
|
+ self.graph,
|
|
|
+ title="Historic Price", title_align='left'
|
|
|
+ ),
|
|
|
+ ])),
|
|
|
+ ])
|
|
|
})
|
|
|
connect_signal(self.buttons['done'], 'click', lambda _: save_and_clear_cb())
|
|
|
connect_signal(self.buttons['clear'], 'click', lambda _: self.clear())
|