Error when using metavar with nargs
Author: carlfischerjbaCreated Jun 1, 2017Updated Aug 20, 2025
Labelsbug2.0
The test below requests two integers and adds them up. When using argparse, I use a tuple metavar to name each value so the user can tell that they represent different things. Gooey doesn't like this and raises a TypeError in components.py:format_title(). Using a GooeyParser doesn't help. Replacing the metavar tuple with a single string works.
Could we tweak the format_title method to accept a tuple of strings?
from argparse import ArgumentParser
from gooey import Gooey
@Gooey
def main_argparse():
parser = ArgumentParser(description='Sum two integers.')
parser.add_argument('integers', type=int, nargs=2, metavar=('first', 'second'))
args = parser.parse_args()
print sum(args.integers)
if __name__=="__main__":
#main_argparse()
main_gooey()
Source: chriskiehl/Gooey