slider based options done

This commit is contained in:
Sander Land committed 2020-06-21 11:53:15 +02:00
1 parent 87a1038546
commit 41c2addbdf
5 files changed
+34 -24

No files matched your search

+6 -6
View File
@@ -158,9 +158,9 @@ class QuickConfigGui(MDBoxLayout):
Clock.schedule_once(self.build_and_set_properties, 0)
def collect_properties(self, widget) -> Dict:
if isinstance(widget, (LabelledTextInput, LabelledSpinner, LabelledCheckBox,LabelledSelectionSlider)) and getattr(
widget, "input_property", None
):
if isinstance(
widget, (LabelledTextInput, LabelledSpinner, LabelledCheckBox, LabelledSelectionSlider)
) and getattr(widget, "input_property", None):
try:
ret = {widget.input_property: widget.input_value}
except Exception as e: # TODO : on widget?
@@ -318,12 +318,12 @@ class ConfigAIPopup(QuickConfigGui):
self.options_grid.clear_widgets()
self.help_label.text = i18n._(strategy.replace("ai:", "aihelp:"))
for k, v in sorted(mode_settings.items(), key=lambda kv: kv[0]):
self.options_grid.add_widget(DescriptionLabel(text=k,size_hint_x=0.25))
self.options_grid.add_widget(DescriptionLabel(text=k, size_hint_x=0.25))
if k in AI_OPTION_VALUES:
values = AI_OPTION_VALUES[k]
if isinstance(values[0],Tuple): # with descriptions, possibly language-specific
if isinstance(values[0], Tuple): # with descriptions, possibly language-specific
fixed_values = [(v, re.sub(r"\[(.*?)\]", lambda m: i18n._(m[1]), l)) for v, l in values]
else: # just numbers
else: # just numbers
fixed_values = [(v, str(v)) for v in values]
widget = LabelledSelectionSlider(values=fixed_values, input_property=f"ai/{strategy}/{k}")
widget.set_value(v)