Browse Source

Fixed Nargs issue (#39)

pull/47/head
chriskiehl 10 years ago
parent
commit
37debcc050
2 changed files with 30 additions and 2 deletions
  1. 10
      gooey/gui/components.py
  2. 22
      gooey/mockapplications/mockapp_nargs.py

10
gooey/gui/components.py

@ -69,10 +69,16 @@ class AbstractComponent(object):
return base_text
def HasNargs(self, action):
return action.nargs == '+' or action.nargs == '?'
return action.nargs is not None and action.nargs is not 0
def CreateNargsMsg(self, action):
return ' (Note: at least 1 or more arguments are required)'
if isinstance(action.nargs, int):
return '\n(Note: exactly {} arguments are required)'.format(action.nargs)
elif action.nargs == '+':
return '\n(Note: at least 1 or more arguments are required)'
return ''
def CreateNameLabelWidget(self, parent, action):
label = str(action.dest).title()

22
gooey/mockapplications/mockapp_nargs.py

@ -0,0 +1,22 @@
import sys
import argparse
from gooey import Gooey
sys.argv.extend(['1', '2', '3', '4', '--sum'])
# @Gooey
def main():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs="+",
help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
const=sum, default=max,
help='sum the integers (default: find the max)')
args = parser.parse_args()
print args.accumulate(args.integers)
if __name__ == '__main__':
main()
Loading…
Cancel
Save