From bd79ea9819586dac09afbb3e23624cbf9d3c744d Mon Sep 17 00:00:00 2001 From: chriskiehl Date: Thu, 7 Jan 2016 23:01:18 -0500 Subject: [PATCH] auto_start option --- gooey/gui/model.py | 2 ++ gooey/gui/presenter.py | 3 +++ gooey/python_bindings/config_generator.py | 2 +- gooey/python_bindings/gooey_decorator.py | 12 +++++------- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/gooey/gui/model.py b/gooey/gui/model.py index ccb69b0..8084bfe 100644 --- a/gooey/gui/model.py +++ b/gooey/gui/model.py @@ -91,8 +91,10 @@ class MyModel(object): self.build_spec = build_spec self.layout_type = self.build_spec['layout_type'] + self.auto_start = self.build_spec['auto_start'] self.progress_regex = self.build_spec['progress_regex'] self.progress_expr = self.build_spec['progress_expr'] + self.program_name = self.build_spec['program_name'] self.default_size = self.build_spec['default_size'] diff --git a/gooey/gui/presenter.py b/gooey/gui/presenter.py index 9b7ab95..8c53cbb 100644 --- a/gooey/gui/presenter.py +++ b/gooey/gui/presenter.py @@ -43,6 +43,9 @@ class Presenter(object): else: self.view.enable_stop_button() + if self.model.auto_start: + self.model.update_state(States.RUNNNING) + self.on_start() self.syncronize_from_model() def update_model(self): diff --git a/gooey/python_bindings/config_generator.py b/gooey/python_bindings/config_generator.py index 0ac07e4..ab6a3cb 100644 --- a/gooey/python_bindings/config_generator.py +++ b/gooey/python_bindings/config_generator.py @@ -18,7 +18,7 @@ def create_from_parser(parser, source_path, **kwargs): 'target': run_cmd, 'program_name': kwargs.get('program_name') or os.path.basename(sys.argv[0]).replace('.py', ''), 'program_description': kwargs.get('program_description', ''), - 'show_config': show_config, + 'auto_start': kwargs.get('auto_start', False), 'show_advanced': kwargs.get('advanced', True), 'default_size': kwargs.get('default_size', (610, 530)), 'num_required_cols': kwargs.get('required_cols', 1), diff --git a/gooey/python_bindings/gooey_decorator.py b/gooey/python_bindings/gooey_decorator.py index 4a63dc6..01276b2 100644 --- a/gooey/python_bindings/gooey_decorator.py +++ b/gooey/python_bindings/gooey_decorator.py @@ -6,23 +6,21 @@ Created on Jan 24, 2014 TODO: this ''' -import sys -import os import json - -from . import config_generator +import os +import sys +from argparse import ArgumentParser from gooey.gui import application - -from argparse import ArgumentParser from gooey.gui.util.freeze import get_resource_path +from . import config_generator IGNORE_COMMAND = '--ignore-gooey' def Gooey(f=None, advanced=True, language='english', - autostart=False, # TODO: add this to the docs. Used to be `show_config=True` + 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),