Browse Source

last big push before packaging

pull/1/head
Chris Kiehl 10 years ago
parent
commit
1f77805af9
82 changed files with 274 additions and 499 deletions
  1. 2
      .pydevproject
  2. 5
      .settings/org.eclipse.core.resources.prefs
  3. 20
      LICENSE.txt
  4. 2
      MANIFEST.in
  5. 70
      README.md
  6. 0
      gooey/TODO.txt
  7. 0
      gooey/app/__init__.py
  8. 0
      gooey/app/dialogs/__init__.py
  9. 0
      gooey/app/dialogs/action_sorter.py
  10. 0
      gooey/app/dialogs/action_sorter_unittest.py
  11. 0
      gooey/app/dialogs/advanced_config.py
  12. 0
      gooey/app/dialogs/advanced_config_unittest.py
  13. 0
      gooey/app/dialogs/argparse_test_data.py
  14. 2
      gooey/app/dialogs/base_window.py
  15. 0
      gooey/app/dialogs/basic_config_panel.py
  16. 0
      gooey/app/dialogs/component_factory.py
  17. 0
      gooey/app/dialogs/component_register.py
  18. 0
      gooey/app/dialogs/component_register_unittest.py
  19. 0
      gooey/app/dialogs/components.py
  20. 0
      gooey/app/dialogs/components_unittest.py
  21. 2
      gooey/app/dialogs/config_model.py
  22. 4
      gooey/app/dialogs/controller.py
  23. 0
      gooey/app/dialogs/display_main.py
  24. 0
      gooey/app/dialogs/footer.py
  25. 0
      gooey/app/dialogs/header.py
  26. 0
      gooey/app/dialogs/imageutil.py
  27. 0
      gooey/app/dialogs/msg_dialog.py
  28. 0
      gooey/app/dialogs/option_reader.py
  29. 0
      gooey/app/dialogs/option_reader_unittest.py
  30. 2
      gooey/app/dialogs/runtime_display_panel.py
  31. 12
      gooey/app/images/__init__.py
  32. 0
      gooey/app/images/alessandro_rei_checkmark.png
  33. 0
      gooey/app/images/computer.png
  34. 0
      gooey/app/images/computer2.png
  35. 0
      gooey/app/images/computer3.png
  36. 0
      gooey/app/images/icon.ico
  37. 16
      gooey/app/images/image_store.py
  38. 0
      gooey/app/images/images.jpg
  39. 0
      gooey/app/images/loader.gif
  40. 0
      gooey/app/images/settings2.png
  41. 0
      gooey/codegen.py
  42. 6
      gooey/gooey.py
  43. 2
      gooey/i18n.py
  44. 0
      gooey/i18n_unittest.py
  45. 0
      gooey/languages/__init__.py
  46. 0
      gooey/languages/eng.py
  47. 0
      gooey/languages/english.json
  48. 0
      gooey/languages/french.json
  49. 0
      gooey/mockapplications/__init__.py
  50. 0
      gooey/mockapplications/example_argparse_souce_in_main.py
  51. 0
      gooey/mockapplications/example_argparse_souce_in_try.py
  52. 11
      gooey/mockapplications/mockapp.py
  53. 0
      gooey/mockapplications/module_with_no_argparse.py
  54. 110
      gooey/monkey_parser.py
  55. 109
      gooey/source_parser.py
  56. 4
      gooey/source_parser_unittest.py
  57. 0
      gooey/test_queue.py
  58. 0
      gooey/themes/__init__.py
  59. 0
      gooey/themes/thm.py
  60. 20
      setup.py
  61. BIN
      src/app/__init__.pyc
  62. BIN
      src/app/dialogs/__init__.pyc
  63. BIN
      src/app/dialogs/advanced_config.pyc
  64. BIN
      src/app/dialogs/component_factory.pyc
  65. BIN
      src/app/dialogs/display_main.pyc
  66. BIN
      src/app/dialogs/footer.pyc
  67. BIN
      src/app/dialogs/header.pyc
  68. 62
      src/app/dialogs/window.py
  69. BIN
      src/app/images/__init__.pyc
  70. BIN
      src/app/images/harwen_monitor.png
  71. 19
      src/app/images/image_store.py
  72. BIN
      src/app/images/image_store.pyc
  73. BIN
      src/app/images/settings.png
  74. BIN
      src/app/images/terminal.png
  75. 56
      src/experiments/command.py
  76. 39
      src/experiments/thread_interupt.py
  77. 0
      src/model/__init__.py
  78. BIN
      src/model/__init__.pyc
  79. BIN
      src/model/codegen.pyc
  80. 142
      src/model/example_argparse_souce.py
  81. 56
      src/model/gui.py
  82. 0
      src/themes/__init__.py

2
.pydevproject

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${PROJECT_DIR_NAME}/src</path>
<path>/${PROJECT_DIR_NAME}/gooey</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">C:\Python27\python.exe</pydev_property>

5
.settings/org.eclipse.core.resources.prefs

@ -1,3 +1,4 @@
eclipse.preferences.version=1
encoding//src/mockapplication/example_argparse_souce_in_try.py=utf-8
encoding//src/model/codegen.py=utf-8
encoding//gooey/codegen.py=utf-8
encoding//gooey/mockapplications/example_argparse_souce_in_main.py=utf-8
encoding//gooey/mockapplications/example_argparse_souce_in_try.py=utf-8

20
LICENSE.txt

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2013 Chris
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

2
MANIFEST.in

@ -0,0 +1,2 @@
include *.txt
recursive-include docs *.txt

70
README.md

@ -1,4 +1,72 @@
Gooey
=====
Turn (almost) any command line program into a full GUI application with one line
(image)
Turn (almost) any command line program into a full GUI application with one line
What is it?
-----------
Gooey converts your Console Applications into end-user friendly GUI applications. It lets you focus on building robust, configurable programs without having to worry about how it will be presented to and interacted with by your average non-techie person.
Why?
---
Because as much as we love the command prompt, the rest of the world looks at it like some horrific relic from the '80s. As I embarked in the world of freelancing, I wanted to deliver something a little more polished than a black box with white text, and something which was easily understandable and configurable to the end-user.
How does it work?
------------------
Gooey is attached to your code via a simple decorator on your `main` method.
@gooey <--- all it takes! :)
def main():
# rest of code
At runtime, it loads the Abstract Syntax Tree of your module and parses it for all references to `ArgumentParser` (The older `optparse` is currently not supported). These references are then extracted and assigned a `component type` based on the function they provide.
Currently, the `ArgumentParser._actions` are mapped to the following components.
| Action | WxWidget |
|:----------------------|-----------|
| store | TextCtrl |
| store_const | CheckBox |
| store_true| CheckBox |
| store_False | CheckBox|
| append | TextCtrl |
| count| DropDown|
|choice| DropDown|
Installation instructions
------------------------
TODO
----
* Get this thing working.
(picture of osx)
* Themes
* update graphics
* robustify parser
* Optparse support? (do people still use it)
Wanna help?
-----------
Do you art? I'd love to swap out the graphics to something more stylistically unified. That ajax loader is pretty out of place..
Image Credits
-------------

src/TODO.txt → gooey/TODO.txt

src/app/__init__.py → gooey/app/__init__.py

src/app/dialogs/__init__.py → gooey/app/dialogs/__init__.py

src/app/dialogs/action_sorter.py → gooey/app/dialogs/action_sorter.py

src/app/dialogs/action_sorter_unittest.py → gooey/app/dialogs/action_sorter_unittest.py

src/app/dialogs/advanced_config.py → gooey/app/dialogs/advanced_config.py

src/app/dialogs/advanced_config_unittest.py → gooey/app/dialogs/advanced_config_unittest.py

src/app/dialogs/argparse_test_data.py → gooey/app/dialogs/argparse_test_data.py

src/app/dialogs/base_window.py → gooey/app/dialogs/base_window.py

@ -19,7 +19,7 @@ from app.dialogs.runtime_display_panel import RuntimeDisplay
from app.dialogs.controller import Controller
from app.images import image_store
from app.dialogs.config_model import ConfigModel
from model.i18n import I18N
from i18n import I18N
class BaseWindow(wx.Frame):

src/app/dialogs/basic_config_panel.py → gooey/app/dialogs/basic_config_panel.py

src/app/dialogs/component_factory.py → gooey/app/dialogs/component_factory.py

src/app/dialogs/component_register.py → gooey/app/dialogs/component_register.py

src/app/dialogs/component_register_unittest.py → gooey/app/dialogs/component_register_unittest.py

src/app/dialogs/components.py → gooey/app/dialogs/components.py

src/app/dialogs/components_unittest.py → gooey/app/dialogs/components_unittest.py

src/app/dialogs/config_model.py → gooey/app/dialogs/config_model.py

@ -6,7 +6,7 @@ Created on Jan 23, 2014
import sys
import types
from model.source_parser import ArgumentError
from monkey_parser import ArgumentError
from app.dialogs.action_sorter import ActionSorter

src/app/dialogs/controller.py → gooey/app/dialogs/controller.py

@ -8,7 +8,7 @@ import wx
import sys
import traceback
from multiprocessing.dummy import Pool, Process
from model.i18n import I18N
from i18n import I18N
YES = 5103
NO = 5104
@ -56,7 +56,7 @@ class Controller(object):
cmd_line_args = self._body.GetOptions()
if not self._model.IsValidArgString(cmd_line_args):
error_msg = self._model.GetErrorMsg(cmd_line_args)
self.ShowDialog(self._translator['error'], error_msg, wx.ICON_ERROR)
self.ShowDialog(self._translator['error_title'], error_msg, wx.ICON_ERROR)
return
self._model.AddToArgv(cmd_line_args)
self._base.NextPage()

src/app/dialogs/display_main.py → gooey/app/dialogs/display_main.py

src/app/dialogs/footer.py → gooey/app/dialogs/footer.py

src/app/dialogs/header.py → gooey/app/dialogs/header.py

src/app/dialogs/imageutil.py → gooey/app/dialogs/imageutil.py

src/app/dialogs/msg_dialog.py → gooey/app/dialogs/msg_dialog.py

src/app/dialogs/option_reader.py → gooey/app/dialogs/option_reader.py

src/app/dialogs/option_reader_unittest.py → gooey/app/dialogs/option_reader_unittest.py

src/app/dialogs/runtime_display_panel.py → gooey/app/dialogs/runtime_display_panel.py

@ -8,7 +8,7 @@ import wx
import sys
import Queue
import threading
from model.i18n import I18N
from i18n import I18N
class MessagePump(object):
def __init__(self):

src/app/images/__init__.py → gooey/app/images/__init__.py

@ -1,15 +1,17 @@
'''
generates the internals of the image_store module
Code generation for the image_store module
Nice perk of this approach is that it turns path errors into
things that lint can catch, rather than something that gets stumbled
upon randomly at runtime.
Loops throught the image package and
At some point early on, I thought this would be waaaaaaaay easier than just
updating the paths by hand. Being that I ended up with just a handful of images,
I was wrong..
'''
import os
PATH = __path__[0]
PATH = os.path.dirname(__file__)
print PATH
def render_class(assignments):

src/app/images/alessandro_rei_checkmark.png → gooey/app/images/alessandro_rei_checkmark.png

src/app/images/computer.png → gooey/app/images/computer.png

src/app/images/computer2.png → gooey/app/images/computer2.png

src/app/images/computer3.png → gooey/app/images/computer3.png

src/app/images/icon.ico → gooey/app/images/icon.ico

16
gooey/app/images/image_store.py

@ -0,0 +1,16 @@
"""
GENERATED CODE: DO NOT EDIT
Simple mapping of image names to their location on disc.
Convenience module for keeping the filepaths in one place.
"""
alessandro_rei_checkmark = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\alessandro_rei_checkmark.png"
computer = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\computer.png"
computer2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\computer2.png"
computer3 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\computer3.png"
icon = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\icon.ico"
loader = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\loader.gif"
settings2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\gooey\app\images\settings2.png"

src/app/images/images.jpg → gooey/app/images/images.jpg

src/app/images/loader.gif → gooey/app/images/loader.gif

src/app/images/settings2.png → gooey/app/images/settings2.png

src/model/codegen.py → gooey/codegen.py

src/model/gooey.py → gooey/gooey.py

@ -15,13 +15,13 @@ from app.dialogs import window
from app.dialogs.base_window import BaseWindow
from app.dialogs.advanced_config import AdvancedConfigPanel
from app.dialogs.basic_config_panel import BasicConfigPanel
from model.i18n import I18N
from i18n import I18N
from functools import partial
def Gooey(f=None, advanced=False,
def Gooey(f=None, advanced=True,
language='english', noconfig=False,
program_name=None):
program_name=None, program_description=None):
'''
Decorator for client code's main function.
Entry point for the GUI generator.

src/model/i18n.py → gooey/i18n.py

@ -14,7 +14,7 @@ class I18N(object):
program.
'''
_instance = None
_default_dir = os.path.join(os.path.dirname(__file__), '..', 'languages')
_default_dir = os.path.join(os.path.dirname(__file__), 'languages')
def __init__(self, language='english'):
''' Create an I18N object '''
self._dict = self._open(self._get_path(language))

src/model/i18n_unittest.py → gooey/i18n_unittest.py

src/experiments/__init__.py → gooey/languages/__init__.py

src/languages/eng.py → gooey/languages/eng.py

src/languages/english.json → gooey/languages/english.json

src/languages/french.json → gooey/languages/french.json

src/languages/__init__.py → gooey/mockapplications/__init__.py

src/mockapplication/example_argparse_souce_in_main.py → gooey/mockapplications/example_argparse_souce_in_main.py

src/mockapplication/example_argparse_souce_in_try.py → gooey/mockapplications/example_argparse_souce_in_try.py

src/mockapplication/mockapp.py → gooey/mockapplications/mockapp.py

@ -8,7 +8,7 @@ import hashlib
from time import time as _time
from time import sleep as _sleep
from argparse import ArgumentParser
from model.gooey import Gooey
from gooey import Gooey
@ -18,10 +18,15 @@ from model.gooey import Gooey
def main():
my_cool_parser = ArgumentParser(description="Mock application to test Gooey's functionality")
# my_cool_parser.add_argument('filename', help="bla bla bla")
my_cool_parser.add_argument("filename", help="Name of the file you want to read") # positional
my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output") # positional
my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from')
my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer")
my_cool_parser.add_argument("-w", "--whatevs", default="No, NOT whatevs", help="...")
my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit")
my_cool_parser.add_argument("-o", "--obfuscate", action="store_true", help="obfuscate the countdown timer!")
my_cool_parser.add_argument('-r', '--recursive', choices=['yes','no'], help='Recurse into subfolders')
my_cool_parser.add_argument("-w", "--writelog", default="No, NOT whatevs", help="write log to some file or something")
print 'inside of main(), my_cool_parser =', my_cool_parser
args = my_cool_parser.parse_args()

src/mockapplication/module_with_no_argparse.py → gooey/mockapplications/module_with_no_argparse.py

110
gooey/monkey_parser.py

@ -0,0 +1,110 @@
'''
Created on Feb 8, 2014
@author: Chris
'''
import types
from argparse import ArgumentParser
class ArgumentError(Exception):
'''Thrown when the parser is supplied with an incorrect argument format'''
pass
class MonkeyParser(object):
'''
Builds a parser instance from the code
extracted from the client module.
The instance is stored as a private variable in the
class and all methods are delagted to it so that the
user of the class can treat it just as a normal argparse
instance.
'''
def __init__(self, source_code):
self._parser_instance = self._build_argparser_from_client_source(source_code)
# Monkey patch parser's `error` method so that it raises an error
# rather than silently exiting
self._parser_instance.error = types.MethodType(
self._ErrorAsString,
self._parser_instance)
def _build_argparser_from_client_source(self, source_code):
'''
runs the client code by evaling each line.
Example input Code:
parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("-r", "--recursive", dest="recurse", action="store_true", help="recurse into subfolders [default: %(default)s]")
parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")
Method extracts the instance name (e.g. parser) from the first line,
and instantiates it in a local variable by evaling the rest of the lines.
Each subsequent line updates the local variable in turn.
'''
new_source_code = self._format_source_with_new_varname('clients_parser', source_code)
# variable of the same name as the one passed into the format_source method.
# Used to hold the eval'd statements
first_line = new_source_code.pop(0)
clients_parser, assignment = self._split_line(first_line)
clients_parser = eval(assignment)
for line in new_source_code:
eval(line)
return clients_parser
def _format_source_with_new_varname(self, variable_name, source):
'''
'injects' the client code with a known variable name so that it
can be `eval`d and assigned to a variable in the local code.
For example, if the client code was:
parser = ArgumentParser(descrip...)
parser.add_argument("-r", "--re...)
parser.add_argument("-v", "--ve...)
The variable "parser" would be overwritten with a custom name. e.g.
my_parser = ArgumentParser(descrip...)
my_parser.add_argument("-r", "--re...)
'''
source_code = source[:]
first_line = source_code[0]
parser_variable, statement = self._split_line(first_line)
parser_variable = parser_variable.strip()
for index, line in enumerate(source_code):
source_code[index] = line.replace(parser_variable, variable_name)
return source_code
def _split_line(self, line):
# Splits line at the first = sign,
# joins everything after the first =
# to account for additional = signs in
# parameters
components = line.split('=')
var = components.pop(0)
return var, '='.join(components)
def __getattr__(self, attr):
'''
Auto-delegates everything to the ArgumentParser instance'''
return getattr(self._parser_instance, attr)
@staticmethod
def _ErrorAsString(self, msg):
'''
Monkey patch for parser.error
Returns the error string rather than
printing and silently exiting.
'''
raise ArgumentError(msg)
if __name__ == '__main__':
pass

src/model/source_parser.py → gooey/source_parser.py

@ -12,15 +12,9 @@ client code.
import os
import ast
import sys
import types
import random
import codegen
import argparse
import cStringIO
from itertools import chain
from argparse import ArgumentParser
from argparse import RawDescriptionHelpFormatter
from monkey_parser import MonkeyParser
from app.dialogs.action_sorter import ActionSorter
@ -28,100 +22,8 @@ class ParserError(Exception):
'''Thrown when the parser can't find argparse functions the client code'''
pass
class ArgumentError(Exception):
'''Thrown when the parser is supplied with an incorrect argument format'''
pass
class ParserFromSource(object):
'''
Builds a parser instance from the code
extracted from the client module.
The instance is stored as a private variabel in the
class and all methods are delagted to it so that the
user of the class can treat it just as a normal argparse
instance.
'''
def __init__(self, source_code):
self._parser_instance = self._build_argparser_from_client_source(source_code)
self._parser_instance.error = types.MethodType(
self._ErrorAsString,
self._parser_instance)
def _build_argparser_from_client_source(self, source_code):
'''
runs the client code by evaling each line.
Example input Code:
parser = ArgumentParser(description=program_license, formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("-r", "--recursive", dest="recurse", action="store_true", help="recurse into subfolders [default: %(default)s]")
parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")
Method extracts the instance name (e.g. parser) from the first line,
and instantiates it in a local variable by evaling the rest of the lines.
Each subsequent line updates the local variable in turn.
'''
new_source_code = self._format_source_with_new_varname('clients_parser', source_code)
# variable of the same name as the one passed into the format_source method.
# Used to hold the eval'd statements
first_line = new_source_code.pop(0)
clients_parser, assignment = self._split_line(first_line)
clients_parser = eval(assignment)
for line in new_source_code:
eval(line)
return clients_parser
def _format_source_with_new_varname(self, variable_name, source):
'''
'injects' the client code with a known variable name so that it
can be `eval`d and assigned to a variable in the local code.
For example, if the client code was:
parser = ArgumentParser(descrip...)
parser.add_argument("-r", "--re...)
parser.add_argument("-v", "--ve...)
The variable "parser" would be overwritten with a custom name. e.g.
my_parser = ArgumentParser(descrip...)
my_parser.add_argument("-r", "--re...)
'''
source_code = source[:]
first_line = source_code[0]
parser_variable, statement = self._split_line(first_line)
parser_variable = parser_variable.strip()
for index, line in enumerate(source_code):
source_code[index] = line.replace(parser_variable, variable_name)
return source_code
def _split_line(self, line):
# Splits line at the first = sign,
# joins everything after the first =
# to account for additional = signs in
# parameters
components = line.split('=')
var = components.pop(0)
return var, '='.join(components)
def __getattr__(self, attr):
'''
Auto-delegates everything to the ArgumentParser instance'''
return getattr(self._parser_instance, attr)
@staticmethod
def _ErrorAsString(self, msg):
'''
Monkey patch for parser.error
Returns the error string rather than
printing and silently exiting.
'''
raise ArgumentError(msg)
def parse_source_file(file_name):
'''
@ -228,6 +130,9 @@ def find_argparse_location(locations):
return None
def convert_to_python(ast_source):
'''
Converts the ast objects back into Python code
'''
return map(codegen.to_source, ast_source)
@ -235,17 +140,17 @@ def extract_parser(modulepath):
ast_source = parse_source_file(modulepath)
if ast_source:
python_code = convert_to_python(ast_source)
return ParserFromSource(python_code)
return MonkeyParser(python_code)
return None
if __name__ == '__main__':
filepath = os.path.join(os.path.dirname(__file__),
'..', 'mockapplication',
'mockapplications',
'example_argparse_souce.py')
ast_source = parse_source_file(filepath)
python_code = convert_to_python(ast_source)
parser = ParserFromSource(python_code)
parser = MonkeyParser(python_code)
factory = ActionSorter(parser._actions)
print factory._positionals

src/model/source_parser_unittest.py → gooey/source_parser_unittest.py

@ -11,13 +11,13 @@ import source_parser
class TestSourceParser(unittest.TestCase):
PATH = os.path.join(os.path.dirname(__file__), '..', 'mockapplication')
PATH = os.path.join(os.path.dirname(__file__), 'mockapplications')
def module_path(self, name):
return os.path.join(self.PATH, name)
def setUp(self):
self._mockapp = self.module_path('mockapplication.py')
self._mockapp = self.module_path('mockapplications.py')
self._module_with_noargparse = self.module_path('module_with_no_argparse.py')
self._module_with_arparse_in_try = self.module_path('example_argparse_souce_in_try.py')
self._module_with_argparse_in_main = self.module_path('example_argparse_souce_in_main.py')

src/model/test_queue.py → gooey/test_queue.py

src/mockapplication/__init__.py → gooey/themes/__init__.py

src/themes/thm.py → gooey/themes/thm.py

20
setup.py

@ -0,0 +1,20 @@
from distutils.core import setup
setup(
name='Gooey',
version='0.1.0',
author='Chris Kiehl',
author_email='ckiehl@gmail.com',
packages=[
'gooey',
'gooey.languages',
'gooey.app',
'gooey.app.dialogs',
'gooey.app.images',
'gooey.mockapplications',
'gooey.themes'],
url='http://pypi.python.org/pypi/TowelStuff/',
license='LICENSE.txt',
description='Useful towel-related stuff.',
long_description=open('README.txt').read()
)

BIN
src/app/__init__.pyc

BIN
src/app/dialogs/__init__.pyc

BIN
src/app/dialogs/advanced_config.pyc

BIN
src/app/dialogs/component_factory.pyc

BIN
src/app/dialogs/display_main.pyc

BIN
src/app/dialogs/footer.pyc

BIN
src/app/dialogs/header.pyc

62
src/app/dialogs/window.py

@ -1,62 +0,0 @@
'''
Created on Jan 19, 2014
@author: Chris
def wrap():
Check if there is a parser in the client code
if parser:
build WindowType based on parser
showWindow()
get user params
pass params to sys.argv.
run client code
else:
Default WindowType
run client code
<wx._gdi.Bitmap; proxy of <Swig Object of type 'wxBitmap *' at 0x2ebf8e0> >
<wx._gdi.Bitmap; proxy of <Swig Object of type 'wxBitmap *' at 0x2ebc830> >
'''
import wx
import advanced_config
from basic_config_panel import BasicConfigPanel
from base_window import BaseWindow
from app.dialogs.config_model import ConfigModel
from app.dialogs import argparse_test_data
def WithAdvancedOptions(BodyPanel, model, payload):
app = wx.App(False)
frame = BaseWindow(BodyPanel, model, payload)
frame.Show(True) # Show the frame.
app.MainLoop()
if __name__ == '__main__':
parser = argparse_test_data.parser
WithAdvancedOptions(parser, None)

BIN
src/app/images/__init__.pyc

BIN
src/app/images/harwen_monitor.png

Before After
Width: 128  |  Height: 128  |  Size: 21 KiB

19
src/app/images/image_store.py

@ -1,19 +0,0 @@
"""
GENERATED CODE: DO NOT EDIT
Simple mapping of image names to their location on disc.
Convenience module for keeping the filepaths in one place.
"""
alessandro_rei_checkmark = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\alessandro_rei_checkmark.png"
computer = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\computer.png"
computer2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\computer2.png"
computer3 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\computer3.png"
harwen_monitor = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\harwen_monitor.png"
icon = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\icon.ico"
loader = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\loader.gif"
settings = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\settings.png"
settings2 = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\settings2.png"
terminal = r"C:\Users\Chris\Dropbox\pretty_gui\Gooey\src\app\images\terminal.png"

BIN
src/app/images/image_store.pyc

BIN
src/app/images/settings.png

Before After
Width: 128  |  Height: 128  |  Size: 16 KiB

BIN
src/app/images/terminal.png

Before After
Width: 128  |  Height: 128  |  Size: 11 KiB

56
src/experiments/command.py

@ -1,56 +0,0 @@
'''
Created on Jan 7, 2014
@author: Chris
'''
import sys
import time
from itertools import izip_longest
def doo(x):
print x
def foo(x):
print x
def zoo():
print 'zoo'
def coo():
print 'coo'
msgs = [[
'msg1',
'msg2'
],[
'msg3',
'msg4'
]]
commands = [[
doo,
foo,
zoo,
coo
],[
doo,
foo,
zoo,
coo
]]
_msgs = iter(msgs)
_cmds = iter(commands)
for i in izip_longest(next(_msgs), next(_cmds), fillvalue=None):
print i

39
src/experiments/thread_interupt.py

@ -1,39 +0,0 @@
'''
Created on Jan 26, 2014
@author: Chris
'''
import time
import threading
from multiprocessing import Process
class MyClass(threading.Thread):
'''
classdocs
'''
def __init__(self):
threading.Thread.__init__(self)
self.start_time = time.time()
def run(self):
while time.time() - self.start_time < 10:
pass
def throw_exception(self):
raise KeyboardInterrupt
if __name__ == '__main__':
a = MyClass()
a.start()
time.sleep(2)
a.exit()
time.sleep(2)
print a.is_alive()
a.join()

0
src/model/__init__.py

BIN
src/model/__init__.pyc

BIN
src/model/codegen.pyc

142
src/model/example_argparse_souce.py

@ -1,142 +0,0 @@
#!/usr/local/bin/python2.7
# encoding: utf-8
'''
bin.example_argparse_souce -- shortdesc
bin.example_argparse_souce is a description
It defines classes_and_methods
@author: user_name
@copyright: 2013 organization_name. All rights reserved.
@license: license
@contact: user_email
@deffield updated: Updated
'''
import sys
import os
from argparse import ArgumentParser
from argparse import RawDescriptionHelpFormatter
__all__ = []
__version__ = 0.1
__date__ = '2013-12-13'
__updated__ = '2013-12-13'
DEBUG = 1
TESTRUN = 0
PROFILE = 0
class CLIError(Exception):
'''Generic exception to raise and log different fatal errors.'''
def __init__(self, msg):
super(CLIError).__init__(type(self))
self.msg = "E: %s" % msg
def __str__(self):
return self.msg
def __unicode__(self):
return self.msg
def main(argv=None): # IGNORE:C0111
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_version_message = '%%(prog)s %s (%s)' % (program_version, program_build_date)
program_shortdesc = __import__('__main__').__doc__.split("\n")[1]
program_license = '''%s
Created by user_name on %s.
Copyright 2013 organization_name. All rights reserved.
Licensed under the Apache License 2.0
http://www.apache.org/licenses/LICENSE-2.0
Distributed on an "AS IS" basis without warranties
or conditions of any kind, either express or implied.
USAGE
''' % (program_shortdesc, str(__date__))
try:
# Setup argument parser
parser = ArgumentParser(description='Example Argparse Program', formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("filename", help="filename")
parser.add_argument("-r", "--recursive", dest="recurse", action="store_true", help="recurse into subfolders [default: %(default)s]")
parser.add_argument("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %(default)s]")
parser.add_argument("-i", "--include", action="append", help="only include paths matching this regex pattern. Note: exclude is given preference over include. [default: %(default)s]", metavar="RE" )
parser.add_argument("-m", "--mycoolargument", help="mycoolargument")
parser.add_argument("-e", "--exclude", dest="exclude", help="exclude paths matching this regex pattern. [default: %(default)s]", metavar="RE" )
parser.add_argument('-V', '--version', action='version')
parser.add_argument('-T', '--tester', choices=['yes','no'])
parser.add_argument(dest="paths", help="paths to folder(s) with source file(s) [default: %(default)s]", metavar="path", nargs='+')
# for i in parser._actions:
# print i
# Process arguments
args = parser.parse_args()
paths = args.paths
verbose = args.verbose
recurse = args.recurse
inpat = args.include
expat = args.exclude
if verbose > 0:
print("Verbose mode on")
if recurse:
print("Recursive mode on")
else:
print("Recursive mode off")
if inpat and expat and inpat == expat:
raise CLIError("include and exclude pattern are equal! Nothing will be processed.")
for inpath in paths:
### do something with inpath ###
print(inpath)
return 0
except KeyboardInterrupt:
### handle keyboard interrupt ###
return 0
except Exception, e:
if DEBUG or TESTRUN:
raise(e)
indent = len(program_name) * " "
sys.stderr.write(program_name + ": " + repr(e) + "\n")
sys.stderr.write(indent + " for help use --help")
return 2
if __name__ == "__main__":
if DEBUG:
sys.argv.append("-h")
# sys.argv.append("-v")
sys.argv.append("-r")
main()
sys.exit()
if TESTRUN:
import doctest
doctest.testmod()
if PROFILE:
import cProfile
import pstats
profile_filename = 'bin.example_argparse_souce_profile.txt'
cProfile.run('main()', profile_filename)
statsfile = open("profile_stats.txt", "wb")
p = pstats.Stats(profile_filename, stream=statsfile)
stats = p.strip_dirs().sort_stats('cumulative')
stats.print_stats()
statsfile.close()
sys.exit(0)
sys.exit(main())

56
src/model/gui.py

@ -1,56 +0,0 @@
'''
Created on Dec 9, 2013
@author: Chris
'''
import wx
import sys
import time
import Queue
import datetime
import threading
from app.dialogs.display_main import MainWindow
from app.images import image_store
class MockApplication(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.start_time = time.time()
def run(self):
while time.time() - self.start_time < 5:
print 'printing message at: %s' % time.time()
time.sleep(.5)
print 'Exiting'
def decorator(main_func=None):
def real_decorator(main_func):
def wrapper():
main_func()
return wrapper
if callable(main_func):
return real_decorator(main_func)
return real_decorator
@decorator
def my_func():
print 'inside my_func'
if __name__ == '__main__':
queue = Queue.Queue()
app = wx.App(False)
frame = MainWindow(queue)
frame.Show(True) # Show the frame.
# mock = MockApplication()
# mock.start()
app.MainLoop()
#

0
src/themes/__init__.py

Loading…
Cancel
Save