diff --git a/gooey/gui/components/widgets/counter.py b/gooey/gui/components/widgets/counter.py index 137f7e3..766d716 100644 --- a/gooey/gui/components/widgets/counter.py +++ b/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) diff --git a/gooey/gui/components/widgets/dropdown.py b/gooey/gui/components/widgets/dropdown.py index 24bfc3f..134e163 100644 --- a/gooey/gui/components/widgets/dropdown.py +++ b/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) diff --git a/gooey/python_bindings/argparse_to_json.py b/gooey/python_bindings/argparse_to_json.py index 2a215a6..ea8fb4f 100644 --- a/gooey/python_bindings/argparse_to_json.py +++ b/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;