Browse Source

[Closes #537] Return Action when calling add_argument

pull/546/head
Tyler Donaldson 4 years ago
committed by Chris
parent
commit
c74f24d733
1 changed files with 4 additions and 2 deletions
  1. 6
      gooey/python_bindings/gooey_parser.py

6
gooey/python_bindings/gooey_parser.py

@ -23,10 +23,11 @@ class GooeyArgumentGroup(_ArgumentGroup):
widget = kwargs.pop('widget', None) widget = kwargs.pop('widget', None)
metavar = kwargs.pop('metavar', None) metavar = kwargs.pop('metavar', None)
options = kwargs.pop('gooey_options', None) options = kwargs.pop('gooey_options', None)
super(GooeyArgumentGroup, self).add_argument(*args, **kwargs)
action = super(GooeyArgumentGroup, self).add_argument(*args, **kwargs)
self.parser._actions[-1].metavar = metavar self.parser._actions[-1].metavar = metavar
self.widgets[self.parser._actions[-1].dest] = widget self.widgets[self.parser._actions[-1].dest] = widget
self.options[self.parser._actions[-1].dest] = options self.options[self.parser._actions[-1].dest] = options
return action
def add_argument_group(self, *args, **kwargs): def add_argument_group(self, *args, **kwargs):
options = kwargs.pop('gooey_options', {}) options = kwargs.pop('gooey_options', {})
@ -85,7 +86,7 @@ class GooeyParser(object):
metavar = kwargs.pop('metavar', None) metavar = kwargs.pop('metavar', None)
options = kwargs.pop('gooey_options', None) options = kwargs.pop('gooey_options', None)
self.parser.add_argument(*args, **kwargs)
action = self.parser.add_argument(*args, **kwargs)
self.parser._actions[-1].metavar = metavar self.parser._actions[-1].metavar = metavar
self.widgets[self.parser._actions[-1].dest] = widget self.widgets[self.parser._actions[-1].dest] = widget
self.options[self.parser._actions[-1].dest] = options self.options[self.parser._actions[-1].dest] = options
@ -95,6 +96,7 @@ class GooeyParser(object):
options or {}, options or {},
**kwargs **kwargs
) )
return action
def add_mutually_exclusive_group(self, *args, **kwargs): def add_mutually_exclusive_group(self, *args, **kwargs):
options = kwargs.pop('gooey_options', {}) options = kwargs.pop('gooey_options', {})

Loading…
Cancel
Save