diff --git a/gooey/examples/__init__.py b/gooey/examples/__init__.py index e69de29..4401167 100644 --- a/gooey/examples/__init__.py +++ b/gooey/examples/__init__.py @@ -0,0 +1,34 @@ +import sys +import time + +program_message = \ +''' +Thanks for checking out out Gooey! + +This is a sample message to demonstrate Gooey's functionality. + +Here's are the arguments you supplied: + +{0} + +------------------------------------- + +Gooey is an ongoing project, so feel free to submit any bugs you find to the +issue tracker on Github[1], or drop me a line at audionautic@gmail.com if ya want. + +[1](https://github.com/chriskiehl/Gooey) + +See ya! + +^_^ + +''' + +def display_message(): + message = program_message.format('\n-'.join(sys.argv[1:])).split('\n') + delay = 1.8 / len(message) + + for line in message: + print line + time.sleep(delay) + diff --git a/gooey/examples/gooey_config.json b/gooey/examples/gooey_config.json index 841f19f..dba38d7 100644 --- a/gooey/examples/gooey_config.json +++ b/gooey/examples/gooey_config.json @@ -2,8 +2,8 @@ "num_optional_cols": 2, "num_required_cols": 2, "show_advanced": true, - "program_name": "widget_demo", - "target": "python c:\\users\\chris\\appdata\\local\\temp\\tmpwkcm2q.py", + "program_name": "Widget Demo", + "target": "python c:\\users\\chris\\appdata\\local\\temp\\tmpph43cj.py", "language": "english", "manual_start": false, "show_config": true, diff --git a/gooey/examples/language_demo_japanese.py b/gooey/examples/language_demo_japanese.py new file mode 100644 index 0000000..38fb485 --- /dev/null +++ b/gooey/examples/language_demo_japanese.py @@ -0,0 +1,57 @@ +''' +Created on Dec 21, 2013 + +@author: Chris +''' + +from gooey import Gooey +from gooey import GooeyParser +from gooey.examples import display_message + +welcome_message = \ +r''' + __ __ _ + \ \ / / | | + \ \ /\ / /__| | ___ ___ _ __ ___ ___ + \ \/ \/ / _ \ |/ __/ _ \| '_ ` _ \ / _ \ + \ /\ / __/ | (_| (_) | | | | | | __/ + ___\/__\/ \___|_|\___\___/|_| |_| |_|\___| + |__ __| + | | ___ + | |/ _ \ + | | (_) | + _|_|\___/ _ _ + / ____| | | | + | | __ ___ ___ ___ _ _| | | + | | |_ |/ _ \ / _ \ / _ \ | | | | | + | |__| | (_) | (_) | __/ |_| |_|_| + \_____|\___/ \___/ \___|\__, (_|_) + __/ | + |___/ +''' + +@Gooey(language='japanese', program_name=u'\u30d7\u30ed\u30b0\u30e9\u30e0\u4f8b') +def arbitrary_function(): + desc = u"\u30b3\u30de\u30f3\u30c9\u30e9\u30a4\u30f3\u5f15\u6570\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044" + file_help_msg = u"\u51e6\u7406\u3057\u305f\u3044\u30d5\u30a1\u30a4\u30eb\u306e\u540d\u524d" + my_cool_parser = GooeyParser(description=desc) + my_cool_parser.add_argument(u"\u30d5\u30a1\u30a4\u30eb\u30d6\u30e9\u30a6\u30b6", help=file_help_msg, widget="FileChooser") # positional + + my_cool_parser.add_argument('-d', u'--\u30c7\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3', default=2, type=int, help=u'\u30d7\u30ed\u30b0\u30e9\u30e0\u51fa\u529b\u306e\u671f\u9593\uff08\u79d2\uff09') + my_cool_parser.add_argument('-s', u'--\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb', type=int, help=u'\u65e5\u6642\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u958b\u59cb\u3059\u3079\u304d', widget='DateChooser') + my_cool_parser.add_argument("-c", u"--\u30b7\u30e7\u30fc\u30bf\u30a4\u30e0", action="store_true", help=u"\u30ab\u30a6\u30f3\u30c8\u30c0\u30a6\u30f3\u30bf\u30a4\u30de\u30fc\u3092\u8868\u793a\u3057\u307e\u3059") + my_cool_parser.add_argument("-p", u"--\u30dd\u30fc\u30ba", action="store_true", help=u"\u4e00\u6642\u505c\u6b62\u306e\u5b9f\u884c") + + args = my_cool_parser.parse_args() + main(args) + + +def main(args): + display_message() + +def here_is_smore(): + pass + + +if __name__ == '__main__': + arbitrary_function() diff --git a/gooey/examples/language_demo_russian.py b/gooey/examples/language_demo_russian.py new file mode 100644 index 0000000..0f0e87c --- /dev/null +++ b/gooey/examples/language_demo_russian.py @@ -0,0 +1,52 @@ +''' +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 +from gooey.examples import display_message + + +@Gooey(language='russian', program_name=u'\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b') +def arbitrary_function(): + desc = u"\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u002c \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c " + file_help_msg = u"\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430\u002c \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c" + my_cool_parser = GooeyParser(description=desc) + my_cool_parser.add_argument(u"\u0432\u044b\u0431\u043e\u0440\u0430\u0444\u0430\u0439\u043b\u043e\u0432", help=file_help_msg, widget="FileChooser") # positional + my_cool_parser.add_argument(u"\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u0421\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c", help=file_help_msg, widget="MultiFileChooser") # positional + + my_cool_parser.add_argument('-d', u'--\u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c', default=2, type=int, help=u'\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0028 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0029 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b') + my_cool_parser.add_argument('-s', u'--\u043a\u0440\u043e\u043d \u002d \u0433\u0440\u0430\u0444\u0438\u043a', type=int, help=u'\u0414\u0430\u0442\u0430', widget='DateChooser') + my_cool_parser.add_argument("-c", "--showtime", action="store_true", help="display the countdown timer") + my_cool_parser.add_argument("-p", "--pause", action="store_true", help="Pause execution") + my_cool_parser.add_argument('-v', '--verbose', action='count') + my_cool_parser.add_argument("-o", "--overwrite", action="store_true", help="Overwrite output file (if present)") + my_cool_parser.add_argument('-r', '--recursive', choices=['yes', 'no'], help='Recurse into subfolders') + my_cool_parser.add_argument("-w", "--writelog", default="writelogs", help="Dump output to local file") + my_cool_parser.add_argument("-e", "--error", action="store_true", help="Stop process on error (default: No)") + 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() + main(args) + + +def main(args): + display_message() + +def here_is_smore(): + pass + + +if __name__ == '__main__': + arbitrary_function() diff --git a/gooey/examples/subparser_demo.py b/gooey/examples/subparser_demo.py index 6b2448d..cc2e515 100644 --- a/gooey/examples/subparser_demo.py +++ b/gooey/examples/subparser_demo.py @@ -5,11 +5,12 @@ Example program to demonstrate Gooey's presentation of subparsers import argparse from gooey import Gooey, GooeyParser +from gooey.examples import display_message running = True -@Gooey(optional_cols=2) +@Gooey(optional_cols=2, program_name="Subparser Demo") def main(): settings_msg = 'Subparser example demonstating bundled configurations ' \ 'for Siege, Curl, and FFMPEG' @@ -62,7 +63,7 @@ def main(): ffmpeg_parser = subs.add_parser('ffmpeg', help='Siege is an http/https regression testing and benchmarking utility') ffmpeg_parser.add_argument('Output', help='Pull down headers from the server and display HTTP transaction', - widget='FileSaver') + widget='FileSaver', type=argparse.FileType) ffmpeg_parser.add_argument('--bitrate', help='set the video bitrate in kbit/s (default = 200 kb/s)', type=str) @@ -87,6 +88,10 @@ def main(): parser.parse_args() + display_message() + + + if __name__ == '__main__': main() diff --git a/gooey/examples/widget_demo.py b/gooey/examples/widget_demo.py index 2d53d57..8add304 100644 --- a/gooey/examples/widget_demo.py +++ b/gooey/examples/widget_demo.py @@ -1,19 +1,5 @@ ''' 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 - -welcome_message = \ -r''' __ __ _ \ \ / / | | \ \ /\ / /__| | ___ ___ _ __ ___ ___ @@ -32,10 +18,17 @@ r''' \_____|\___/ \___/ \___|\__, (_|_) __/ | |___/ + +@author: Chris ''' -@Gooey(dump_build_config=True) -def arbitrary_function(): +from gooey import Gooey +from gooey import GooeyParser +from gooey.examples import display_message + + +@Gooey(dump_build_config=True, program_name="Widget Demo") +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) @@ -57,26 +50,13 @@ def arbitrary_function(): 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() - main(args) - - -def main(args): - message = welcome_message.split('\n') - - delay = float(args.duration) / len(message) - print('Printing welcome message over a period of %s seconds' % args.duration) - for line in message: - print line - _sleep(delay) - print('All done!') + display_message() def here_is_smore(): pass if __name__ == '__main__': - arbitrary_function() + main()