From ee1ed8abacaeba24709e82a8c2e89e07953f6040 Mon Sep 17 00:00:00 2001 From: Alexander Gordeyev Date: Fri, 23 Oct 2015 18:37:01 +0300 Subject: [PATCH] add progress bar examples --- gooey/_tmp/example_progress_bar_1.py | 23 +++++++++++++++++++++++ gooey/_tmp/example_progress_bar_2.py | 26 ++++++++++++++++++++++++++ gooey/_tmp/example_progress_bar_3.py | 26 ++++++++++++++++++++++++++ gooey/languages/english.json | 2 +- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 gooey/_tmp/example_progress_bar_1.py create mode 100644 gooey/_tmp/example_progress_bar_2.py create mode 100644 gooey/_tmp/example_progress_bar_3.py diff --git a/gooey/_tmp/example_progress_bar_1.py b/gooey/_tmp/example_progress_bar_1.py new file mode 100644 index 0000000..7969ea3 --- /dev/null +++ b/gooey/_tmp/example_progress_bar_1.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals +from __future__ import print_function +import sys +from time import sleep +from gooey import Gooey, GooeyParser + + +@Gooey(progress_regex=r"^progress: (\d+)%$") +def main(): + parser = GooeyParser(prog="example_progress_bar_1") + _ = parser.parse_args(sys.argv[1:]) + + for i in range(100): + print("progress: {}%".format(i+1)) + sys.stdout.flush() + sleep(0.1) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/gooey/_tmp/example_progress_bar_2.py b/gooey/_tmp/example_progress_bar_2.py new file mode 100644 index 0000000..30e0b60 --- /dev/null +++ b/gooey/_tmp/example_progress_bar_2.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals +from __future__ import print_function +import sys +from time import sleep +from gooey import Gooey, GooeyParser + + +@Gooey(progress_regex=r"^progress: (\d+)/(\d+)$", + progress_expr="x[0] / x[1] * 100") +def main(): + parser = GooeyParser(prog="example_progress_bar_2") + parser.add_argument("steps", type=int, default=15) + parser.add_argument("delay", type=int, default=1) + args = parser.parse_args(sys.argv[1:]) + + for i in range(args.steps): + print("progress: {}/{}".format(i+1, args.steps)) + sys.stdout.flush() + sleep(args.delay) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/gooey/_tmp/example_progress_bar_3.py b/gooey/_tmp/example_progress_bar_3.py new file mode 100644 index 0000000..e3d062f --- /dev/null +++ b/gooey/_tmp/example_progress_bar_3.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals +from __future__ import print_function +import sys +from time import sleep +from gooey import Gooey, GooeyParser + + +@Gooey(progress_regex=r"^progress: (?P\d+)/(?P\d+)$", + progress_expr="current / total * 100") +def main(): + parser = GooeyParser(prog="example_progress_bar_3") + parser.add_argument("steps", type=int, default=15) + parser.add_argument("delay", type=int, default=1) + args = parser.parse_args(sys.argv[1:]) + + for i in range(args.steps): + print("progress: {}/{}".format(i+1, args.steps)) + sys.stdout.flush() + sleep(args.delay) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/gooey/languages/english.json b/gooey/languages/english.json index 136190c..a389ca2 100644 --- a/gooey/languages/english.json +++ b/gooey/languages/english.json @@ -22,7 +22,7 @@ "edit": "Edit", "success_message": "Program completed sucessfully!", "sure_you_want_to_exit": "Are you sure you want to exit?", - "sure_you_want_to_stop": "Are you sure you want to stop the task? \nInterruption can corrupt your data!!", + "sure_you_want_to_stop": "Are you sure you want to stop the task? \nInterruption can corrupt your data!", "uh_oh": "\nUh oh! Looks like there was a problem. \nCopy the text from status window to let your developer know what went wrong.\n", "browse": "Browse" }