Skip to content

Commit

Permalink
Fixes Hop Table Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbob88 committed Apr 14, 2019
1 parent 3098350 commit a281ec1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions beer_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ def make_treeview():
self.scrolled_tree_hops.column("#0",width="90", anchor="w",minwidth="20",stretch="1")

for column in self.hop_columns:
self.scrolled_tree_hops.heading(column, text=column, command=lambda: self.sort_by_hop(column))
self.scrolled_tree_hops.heading(column, text=column, command=lambda column=column: self.sort_by_hop(column))
if column != 'lb:oz' and column != '%':
self.scrolled_tree_hops.column(column, width=40, anchor="center")
elif column == 'lb:oz':
Expand Down Expand Up @@ -1405,7 +1405,6 @@ def sort_by_grist(self, column):
def sort_by_hop(self, column):
# [{'Name': 'Nelson Sauvin', 'Values': {'Type': 'Whole', 'Alpha': 12.7, 'Time': 0.0, 'Util': 0.0, 'ibu': 0.0, 'lb:oz': (0.0,0.0), 'Grams': 0.0, 'Percent': 0.0}}]
old_hops = self.hops

if column == 'Hop Variety':
self.hops = sorted(self.hops, key=lambda k: k['Name'])
elif column == 'Type':
Expand All @@ -1424,7 +1423,6 @@ def sort_by_hop(self, column):
self.hops = sorted(self.hops, key=lambda k: k['Values']['Grams'])
elif column == '%':
self.hops = sorted(self.hops, key=lambda k: k['Values']['Percent'])

if old_hops == self.hops:
self.hops.reverse()
self.refresh_hop()
Expand Down
4 changes: 1 addition & 3 deletions beer_engine2.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def make_treeview():
self.scrolled_tree_hops.column(u"#0",width=u"90", anchor=u"w",minwidth=u"20",stretch=u"1")

for column in self.hop_columns:
self.scrolled_tree_hops.heading(column, text=column, command=lambda: self.sort_by_hop(column))
self.scrolled_tree_hops.heading(column, text=column, command=lambda column=column: self.sort_by_hop(column))
if column != u'lb:oz' and column != u'%':
self.scrolled_tree_hops.column(column, width=40, anchor=u"center")
elif column == u'lb:oz':
Expand Down Expand Up @@ -1409,7 +1409,6 @@ def sort_by_grist(self, column):
def sort_by_hop(self, column):
# [{'Name': 'Nelson Sauvin', 'Values': {'Type': 'Whole', 'Alpha': 12.7, 'Time': 0.0, 'Util': 0.0, 'ibu': 0.0, 'lb:oz': (0.0,0.0), 'Grams': 0.0, 'Percent': 0.0}}]
old_hops = self.hops

if column == u'Hop Variety':
self.hops = sorted(self.hops, key=lambda k: k[u'Name'])
elif column == u'Type':
Expand All @@ -1428,7 +1427,6 @@ def sort_by_hop(self, column):
self.hops = sorted(self.hops, key=lambda k: k[u'Values'][u'Grams'])
elif column == u'%':
self.hops = sorted(self.hops, key=lambda k: k[u'Values'][u'Percent'])

if old_hops == self.hops:
self.hops.reverse()
self.refresh_hop()
Expand Down

0 comments on commit a281ec1

Please sign in to comment.