1
0

add 'sat' as base unit option

This commit is contained in:
SomberNight
2018-05-05 12:42:17 +02:00
parent a459eea018
commit c03d68d758
5 changed files with 39 additions and 33 deletions

View File

@@ -44,14 +44,19 @@ Builder.load_string('''
class ChoiceDialog(Factory.Popup):
def __init__(self, title, choices, key, callback):
def __init__(self, title, choices, key, callback, keep_choice_order=False):
Factory.Popup.__init__(self)
print(choices, type(choices))
if keep_choice_order:
orig_index = {choice: i for (i, choice) in enumerate(choices)}
sort_key = lambda x: orig_index[x[0]]
else:
sort_key = lambda x: x
if type(choices) is list:
choices = dict(map(lambda x: (x,x), choices))
layout = self.ids.choices
layout.bind(minimum_height=layout.setter('height'))
for k, v in sorted(choices.items()):
for k, v in sorted(choices.items(), key=sort_key):
l = Label(text=v)
l.height = '48dp'
l.size_hint_x = 4