Browse Source

closes #284 - dropdowns in required section fail default input validation test

pull/473/head
Chris 6 years ago
parent
commit
5779f3569e
3 changed files with 13 additions and 7 deletions
  1. 4
      gooey/gui/components/widgets/counter.py
  2. 7
      gooey/gui/components/widgets/dropdown.py
  3. 9
      gooey/python_bindings/argparse_to_json.py

4
gooey/gui/components/widgets/counter.py

@ -8,9 +8,5 @@ class Counter(Dropdown):
def setValue(self, value):
self.widget.SetSelection(value)
def getWidgetValue(self):
return self.widget.GetValue()
def formatOutput(self, metadata, value):
return formatters.counter(metadata, value)

7
gooey/gui/components/widgets/dropdown.py

@ -30,7 +30,12 @@ class Dropdown(TextContainer):
self.widget.SetSelection(index)
def getWidgetValue(self):
return self.widget.GetValue()
value = self.widget.GetValue()
# filter out the extra default option that's
# appended during creation
if value == _('select_option'):
return None
return value
def formatOutput(self, metadata, value):
return formatters.dropdown(metadata, value)

9
gooey/python_bindings/argparse_to_json.py

@ -310,9 +310,14 @@ def build_radio_group(mutex_group, widget_group, options):
def action_to_json(action, widget, options):
dropdown_types = {'Listbox', 'Dropdown', 'Counter'}
if action.required:
# check that it's present and not just spaces
validator = 'user_input and not user_input.isspace()'
# Text fields get a default check that user input is present
# and not just spaces, dropdown types get a simplified
# is-it-present style check
validator = ('user_input and not user_input.isspace()'
if widget not in dropdown_types
else 'user_input')
error_msg = 'This field is required'
else:
# not required; do nothing;

Loading…
Cancel
Save