def subparser_presentation_model(build_spec_subparser): app = wx.App(False) i18n.load(get_resource_path('languages'), 'english') model = MyModel(build_spec_subparser) view = MagicMock() presentation = Presenter(view, model) return presentation
def presentation_model(build_spec): app = wx.App(False) i18n.load(get_resource_path('languages'), build_spec['language']) model = MyModel(build_spec) view = MagicMock() presentation = Presenter(view, model) return presentation
def Gooey( f=None, advanced=True, language='english', auto_start=False, # TODO: add this to the docs. Used to be `show_config=True` target=None, program_name=None, program_description=None, default_size=(610, 530), required_cols=2, optional_cols=2, dump_build_config=False, load_build_config=None, monospace_display=False, # TODO: add this to the docs image_dir='default', language_dir=get_resource_path('languages'), progress_regex=None, # TODO: add this to the docs progress_expr=None, # TODO: add this to the docs disable_progress_bar_animation=False, disable_stop_button=False, group_by_type=True): # TODO: add this to the docs ''' Decorator for client code's main function. Serializes argparse data to JSON for use with the Gooey front end ''' params = locals() def build(payload): def run_gooey(self, args=None, namespace=None): source_path = sys.argv[0] build_spec = None if load_build_config: try: build_spec = json.load(open(load_build_config, "r")) except Exception, e: print( 'Exception loading Build Config from {0}: {1}'.format( load_build_config, e)) sys.exit(1) if not build_spec: build_spec = config_generator.create_from_parser( self, source_path, payload_name=payload.__name__, **params) if dump_build_config: config_path = os.path.join(os.getcwd(), 'gooey_config.json') print 'Writing Build Config to: {}'.format(config_path) with open(config_path, 'w') as f: f.write(json.dumps(build_spec, indent=2)) application.run(build_spec) def inner2(*args, **kwargs): ArgumentParser.original_parse_args = ArgumentParser.parse_args ArgumentParser.parse_args = run_gooey return payload(*args, **kwargs) inner2.__name__ = payload.__name__ return inner2
def Gooey(f=None, advanced=True, language='english', auto_start=False, # TODO: add this to the docs. Used to be `show_config=True` program_name=None, program_description=None, default_size=(610, 530), required_cols=2, optional_cols=2, dump_build_config=False, load_build_config=None, monospace_display=False, # TODO: add this to the docs image_dir='default', language_dir=get_resource_path('languages'), progress_regex=None, # TODO: add this to the docs progress_expr=None, # TODO: add this to the docs disable_progress_bar_animation=False, disable_stop_button=False, group_by_type=True): # TODO: add this to the docs ''' Decorator for client code's main function. Serializes argparse data to JSON for use with the Gooey front end ''' params = locals() def build(payload): def run_gooey(self, args=None, namespace=None): source_path = sys.argv[0] build_spec = None if load_build_config: try: build_spec = json.load(open(load_build_config, "r")) except Exception, e: print( 'Exception loading Build Config from {0}: {1}'.format(load_build_config, e)) sys.exit(1) if not build_spec: build_spec = config_generator.create_from_parser(self, source_path, payload_name=payload.__name__, **params) if dump_build_config: config_path = os.path.join(os.getcwd(), 'gooey_config.json') print 'Writing Build Config to: {}'.format(config_path) with open(config_path, 'w') as f: f.write(json.dumps(build_spec, indent=2)) application.run(build_spec) def inner2(*args, **kwargs): ArgumentParser.original_parse_args = ArgumentParser.parse_args ArgumentParser.parse_args = run_gooey return payload(*args, **kwargs) inner2.__name__ = payload.__name__ return inner2
def init(image_dir): ''' initalize the images from the default directory path ''' defaults = { variable_name: os.path.join(image_dir, filename) for variable_name, filename in _image_details } globals().update(defaults) def patch_images(new_image_dir): ''' Loads custom images from the user supplied directory ''' pathto = partial(os.path.join, new_image_dir) if new_image_dir != 'default': if not os.path.isdir(new_image_dir): raise IOError( 'Unable to find the user supplied directory {}'.format( new_image_dir)) new_images = ((varname, pathto(filename)) for varname, filename in _image_details if os.path.exists(pathto(filename))) # push the changes into module scope globals().update(new_images) default_dir = get_resource_path('images') init(default_dir)
Loads custom images from the user supplied directory ''' pathto = partial(os.path.join, new_image_dir) if new_image_dir != 'default': if not os.path.isdir(new_image_dir): raise IOError('Unable to find the user supplied directory {}'.format(new_image_dir)) new_images = ((varname, pathto(filename)) for varname, filename in _image_details if os.path.exists(pathto(filename))) # push the changes into module scope globals().update(new_images) default_dir = get_resource_path('images') init(default_dir)