Commit b765bfcb authored by Martin Schrön's avatar Martin Schrön
Browse files

New Units presentation in TextInputs and improved examples cfg comments

parent 8b96f528
......@@ -288,9 +288,9 @@ working_dir = os.getcwd()
class TextInputMD(MDTextField):
def __init__(self, label='', units='', **kwargs):
if units == '':
units = '-'
kwargs['hint_text'] = label + ' (%s)' % units
if units != '':
units = ' (%s)' % units
kwargs['hint_text'] = label + units
#kwargs['helper_text'] = '(%s)' % units
super().__init__(**kwargs)
......@@ -495,6 +495,7 @@ re_table = re.compile(r'\(table\)')
re_selectone = re.compile(r'\(select one\)')
re_selectany = re.compile(r'\(select any\)')
re_selectitems = re.compile(r'^\# - (.+) \# (.+)')
re_units = re.compile(r'^\# Units: (.+)')
re_yesno = re.compile(r'\(yes\/no\)')
##################################
......@@ -860,6 +861,7 @@ class Root(BoxLayout):
self.__sv_llayout = []
self.__item_type = ''
self.__units = ''
self.__selectitems = []
self.__selectitemc = []
self.__multiline_attach = False
......@@ -948,9 +950,14 @@ class Root(BoxLayout):
"""
self.config_lines.append(line)
match2 = re_selectitems.search(line)
match3 = re_units.search(line)
if match2:
# Items for selection (# - ... # ...)
self.__selectitems.append(match2.group(1).strip())
self.__selectitemc.append(match2.group(2).strip())
elif match3:
# Units comment (# Units: ... .)
self.__units = match3.group(1)
else:
comment = match.group(1)
# make new label
......@@ -1031,8 +1038,9 @@ class Root(BoxLayout):
"""
self.__gr.select_container = MDStackLayout(size_hint=(0.6, 1)) #size_hint=(1, None))
for i in range(len(self.__selectitems)):
#print(i, self.__selectitems[i])
self.__gr.file_input = SelectChip_or(text=self.__selectitems[i], active=True if val==self.__selectitems[i] else False)
#print(i, self.__gr.file_input)
self.__gr.select_container.add_widget(self.__gr.file_input)
if val==self.__selectitems[i]:
self.config_keys[key] = self.__gr.file_input
......@@ -1040,6 +1048,7 @@ class Root(BoxLayout):
if not key in self.config_keys:
# If none is selected, just take a random chip.
# In the evaluation, will loop through .parent.children anyway.
#print(key, self.__selectitems)
self.config_keys[key] = self.__gr.file_input
self.__gr.add_widget(self.__gr.select_container)
......@@ -1077,8 +1086,9 @@ class Root(BoxLayout):
"""
... -> TextField
"""
self.__gr =TextInputMD(label=key, units='in m', multiline=False, text=val, size_hint=(1, None))
self.__gr = TextInputMD(label=key, units=self.__units, multiline=False, text=val, size_hint=(1, None))
self.config_keys[key] = self.__gr #.file_input
self.__units = '' # reset units
if self.__ss < 0:
self.__sv_llayout[self.__s].add_widget(self.__gr)
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment