Browse Source

fix: empty optional arguments are not supplied from Gooey back to the script anymore (and thus their default values can be managed by argparse)

Signed-off-by: Stephen L. <lrq3000@gmail.com>
pull/90/merge
Stephen L 9 years ago
committed by chriskiehl
parent
commit
3708d25a12
3 changed files with 16 additions and 7 deletions
  1. 8
      gooey/gui/components.py
  2. 5
      gooey/gui/widgets/widget_pack.py
  3. 10
      gooey/gui/windows/advanced_config.py

8
gooey/gui/components.py

@ -332,7 +332,7 @@ class Optional(AbstractComponent):
'''
self.AssertInitialization('Optional')
value = self._widget.GetValue()
if not value:
if not value or len(value) <= 0:
return None
return ' '.join(
[self._action.option_strings[0], # get the verbose copy if available
@ -387,8 +387,10 @@ class Flag(AbstractComponent):
returns
Options name for argument (-v)
'''
if self._widget.GetValue():
return self._action.option_strings[0]
if not self._widget.GetValue() or len(self._widget.GetValue()) <= 0:
return None
else:
return self._action.option_strings[0]
def Update(self, size):
'''

5
gooey/gui/widgets/widget_pack.py

@ -58,10 +58,11 @@ class BaseChooser(WidgetPack):
return widget_sizer
def getValue(self):
if self.option_string:
if self.option_string and self.text_box.GetValue() and len(self.text_box.GetValue()) > 0:
return '{0} "{1}"'.format(self.option_string, self.text_box.GetValue())
else:
return '"{}"'.format(self.text_box.GetValue())
#return '"{}"'.format(self.text_box.GetValue())
return None
def onButton(self, evt):
raise NotImplementedError

10
gooey/gui/windows/advanced_config.py

@ -114,10 +114,16 @@ class AdvancedConfigPanel(ScrolledPanel, OptionReader):
return ' '.join(values)
def GetRequiredArgs(self):
return [arg.GetValue() for arg in self.components.required_args]
if not self.components.required_args:
return None
else:
return [arg.GetValue() for arg in self.components.required_args]
def GetOptionalArgs(self):
return [arg.GetValue() for arg in
if not self.components.general_args:
return None
else:
return [arg.GetValue() for arg in
chain(self.components.general_options, self.components.flags)]

Loading…
Cancel
Save