Browse Source

Fixed program_name not working (issue #88). Corrected default name to pull from sys.argv

pull/90/merge
chriskiehl 9 years ago
parent
commit
0ce9085831
2 changed files with 3 additions and 2 deletions
  1. 3
      gooey/python_bindings/config_generator.py
  2. 2
      gooey/python_bindings/gooey_decorator.py

3
gooey/python_bindings/config_generator.py

@ -1,4 +1,5 @@
import os import os
import sys
import argparse_to_json import argparse_to_json
from gooey.gui.windows import layouts from gooey.gui.windows import layouts
from gooey.python_bindings import source_parser from gooey.python_bindings import source_parser
@ -12,7 +13,7 @@ def create_from_parser(parser, source_path, **kwargs):
build_spec = { build_spec = {
'language': kwargs.get('language', 'english'), 'language': kwargs.get('language', 'english'),
'target': run_cmd, 'target': run_cmd,
'program_name': kwargs.get('program_name') or os.path.basename(source_path).replace('.py', ''),
'program_name': kwargs.get('program_name') or os.path.basename(sys.argv[0]).replace('.py', ''),
'program_description': kwargs.get('program_description', ''), 'program_description': kwargs.get('program_description', ''),
'show_config': show_config, 'show_config': show_config,
'show_advanced': kwargs.get('show_advanced', True), 'show_advanced': kwargs.get('show_advanced', True),

2
gooey/python_bindings/gooey_decorator.py

@ -120,7 +120,7 @@ def Gooey(f=None,
def inner2(*args, **kwargs): def inner2(*args, **kwargs):
ArgumentParser.original_parse_args = ArgumentParser.parse_args ArgumentParser.original_parse_args = ArgumentParser.parse_args
ArgumentParser.parse_args = run_gooey ArgumentParser.parse_args = run_gooey
return f(*args, **kwargs)
return payload(*args, **kwargs)
inner2.__name__ = payload.__name__ inner2.__name__ = payload.__name__
return inner2 return inner2

Loading…
Cancel
Save