diff --git a/gooey/_tmp/responding_to_error.py b/gooey/_tmp/responding_to_error.py new file mode 100644 index 0000000..ae1906e --- /dev/null +++ b/gooey/_tmp/responding_to_error.py @@ -0,0 +1,54 @@ +''' +Created on Dec 21, 2013 + +@author: Chris +''' +import sys +import hashlib +from time import time as _time +from time import sleep as _sleep + +from gooey import Gooey +from gooey import GooeyParser + + +def main(): + desc = "Example application to show Gooey's various widgets" + my_cool_parser = GooeyParser(description=desc) + my_cool_parser.add_argument("Example", help="fill ", widget="FileChooser") # positional + verbosity = my_cool_parser.add_mutually_exclusive_group() + verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details") + verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error") + print my_cool_parser._actions + print 'inside of main(), my_cool_parser =', my_cool_parser + + args = my_cool_parser.parse_args() + print sys.argv + print args.countdown + print args.showtime + + start_time = _time() + print 'Counting down from %s' % args.countdown + while _time() - start_time < args.countdown: + if args.showtime: + print 'printing message at: %s' % _time() + else: + print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest() + _sleep(.5) + print 'Finished running the program. Byeeeeesss!' + +def here_is_smore(): + pass + + +if __name__ == '__main__': + print sys.argv + main() + # import inspect + # import dis + # # print dir(main.__code__) + # # for i in dir(main.__code__): + # # print i, getattr(main.__code__, i) + # print dis.dis(main.__code__) + # # for i in inspect.getmembers(main): + # # print i diff --git a/gooey/examples/_gooey_generated_files_/gooey_widget_demo.py b/gooey/examples/_gooey_generated_files_/gooey_widget_demo.py new file mode 100644 index 0000000..7d00387 --- /dev/null +++ b/gooey/examples/_gooey_generated_files_/gooey_widget_demo.py @@ -0,0 +1,66 @@ +''' +Created on Dec 21, 2013 + +@author: Chris +''' +import sys +import hashlib +from time import time as _time +from time import sleep as _sleep + +from gooey import Gooey +from gooey import GooeyParser + + +def main(): + desc = "Example application to show Gooey's various widgets" + file_help_msg = "Name of the file you want to process" + my_cool_parser = GooeyParser(description=desc) + my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional + my_cool_parser.add_argument("directory", help="Directory to store output") # positional + + my_cool_parser.add_argument('-c', '--countdown', default=2, type=int, help='sets the time to count down from you see its quite simple!') + my_cool_parser.add_argument('-j', '--cron-schedule', type=int, help='Set the datetime when the cron should begin', widget='DateChooser') + my_cool_parser.add_argument("-s", "--showtime", action="store_true", help="display the countdown timer") + my_cool_parser.add_argument("-d", "--delay", action="store_true", help="Delay execution for a bit") + my_cool_parser.add_argument('-v', '--verbose', action='count') + 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") + my_cool_parser.add_argument("-e", "--expandAll", action="store_true", help="expand all processes") + verbosity = my_cool_parser.add_mutually_exclusive_group() + verbosity.add_argument('-t', '--verbozze', dest='verbose', action="store_true", help="Show more details") + verbosity.add_argument('-q', '--quiet', dest='quiet', action="store_true", help="Only output on error") + print my_cool_parser._actions + print 'inside of main(), my_cool_parser =', my_cool_parser + + args = my_cool_parser.parse_args() + print sys.argv + print args.countdown + print args.showtime + + start_time = _time() + print 'Counting down from %s' % args.countdown + while _time() - start_time < args.countdown: + if args.showtime: + print 'printing message at: %s' % _time() + else: + print 'printing message at: %s' % hashlib.md5(str(_time())).hexdigest() + _sleep(.5) + print 'Finished running the program. Byeeeeesss!' + +def here_is_smore(): + pass + + +if __name__ == '__main__': + print sys.argv + main() + # import inspect + # import dis + # # print dir(main.__code__) + # # for i in dir(main.__code__): + # # print i, getattr(main.__code__, i) + # print dis.dis(main.__code__) + # # for i in inspect.getmembers(main): + # # print i diff --git a/gooey/python_bindings/gooey_decorator.py b/gooey/python_bindings/gooey_decorator.py index f4b3385..8f84c90 100644 --- a/gooey/python_bindings/gooey_decorator.py +++ b/gooey/python_bindings/gooey_decorator.py @@ -3,6 +3,9 @@ Created on Jan 24, 2014 @author: Chris +Hey, whaduya know. This is out of date again. TODO: update giant doctring. + + ##How things work these days (though, likely to change) The decorator is used solely as a nice way to get the location @@ -42,25 +45,15 @@ done. ''' -from argparse import ArgumentParser as RealArgParser, ArgumentParser - -from functools import partial import os -import sys -import types - import wx - -import tempfile - +import source_parser +from functools import partial from gooey.gui.lang import i18n from gooey.gui.windows import layouts from gooey.python_bindings import argparse_to_json -import source_parser -ROOT_DIR = os.path.dirname(__import__(__name__.split('.')[0]).__file__) -TMP_DIR = tempfile.mkdtemp() def Gooey(f=None, advanced=True, language='english', show_config=True, @@ -84,8 +77,8 @@ def Gooey(f=None, advanced=True, _, filename = os.path.split(main_module_path) cleaned_source = clean_source(main_module_path) - filepath = os.path.join(TMP_DIR, filename) - print(filepath) + filepath = os.path.join(create_local_storage(), 'gooey_' + filename) + with open(filepath, 'w') as f: f.write(cleaned_source) @@ -173,6 +166,14 @@ def has_argparse(source): return any(bla) +def create_local_storage(): + path = os.path.join(os.getcwd(), '_gooey_generated_files_') + try: + os.mkdir(path) + except OSError: + pass # already exists + return path + if __name__ == '__main__': pass