Browse Source

Fixed a bug where the noconfig path was failing

pull/1/head
Chris Kiehl 10 years ago
parent
commit
2f14965e0b
4 changed files with 37 additions and 18 deletions
  1. 2
      src/app/dialogs/advanced_config_unittest.py
  2. 13
      src/app/dialogs/config_model.py
  3. BIN
      src/app/images/image_store.pyc
  4. 40
      src/model/gooey.py

2
src/app/dialogs/advanced_config_unittest.py

@ -11,7 +11,7 @@ import unittest
import advanced_config
import argparse_test_data
from argparse import ArgumentParser
from config_model import ConfigModel
from app.dialogs.config_model import ConfigModel
class TestAdvancedConfigPanel(unittest.TestCase):

13
src/app/dialogs/config_model.py

@ -51,7 +51,20 @@ class ConfigModel(object):
def AddToArgv(self, arg_string):
sys.argv.extend(arg_string.split())
class EmptyConfigModel(object):
def __init__(self):
'''
initializes a BlankModel object
As you can see. This class does nothing..
'''
self.description = ''
if __name__ == '__main__':

BIN
src/app/images/image_store.pyc

40
src/model/gooey.py

@ -9,7 +9,8 @@ import wx
import sys
import argparse
import source_parser
from app.dialogs.config_model import ConfigModel
from app.dialogs.config_model import ConfigModel, EmptyConfigModel
from app.dialogs import window
from app.dialogs.base_window import BaseWindow
from app.dialogs.advanced_config import AdvancedConfigPanel
@ -18,8 +19,8 @@ from model.i18n import I18N
from functools import partial
def Gooey(f=None, advanced=True,
language='english', noconfig=True,
def Gooey(f=None, advanced=False,
language='english', noconfig=False,
program_name=None):
'''
Decorator for client code's main function.
@ -36,26 +37,31 @@ def Gooey(f=None, advanced=True,
def inner():
module_path = get_caller_path()
# User doesn't want to display configuration screen
# Just straight to the run panel
# Must be called before anything else
app = wx.App(False)
try:
parser = source_parser.extract_parser(module_path)
except source_parser.ParserError:
raise source_parser.ParserError(
'Could not locate ArgumentParser statements.'
'\nPlease checkout github.com/chriskiehl/gooey to file a bug')
model = ConfigModel(parser)
if advanced:
BodyPanel = partial(AdvancedConfigPanel, model=model)
if not noconfig:
try:
parser = source_parser.extract_parser(module_path)
except source_parser.ParserError:
raise source_parser.ParserError(
'Could not locate ArgumentParser statements.'
'\nPlease checkout github.com/chriskiehl/gooey to file a bug')
model = ConfigModel(parser)
if advanced:
BodyPanel = partial(AdvancedConfigPanel, model=model)
else:
BodyPanel = BasicConfigPanel
# User doesn't want to display configuration screen
# Just jump straight to the run panel
else:
BodyPanel = BasicConfigPanel
model = EmptyConfigModel()
app = wx.App(False)
frame = BaseWindow(BodyPanel, model, f, params)
if noconfig:
# gah, ugly.. not sure how else to go
# gah, hacky.. not sure how else to go
# about it without rewriting a *bunch* of other stuff
frame.ManualStart()
frame.Show(True)

Loading…
Cancel
Save