diff --git a/gooey/__init__.py b/gooey/__init__.py index 5815894..8ee9854 100644 --- a/gooey/__init__.py +++ b/gooey/__init__.py @@ -1 +1,2 @@ from gooey.python_bindings.gooey_decorator import Gooey +from gooey.python_bindings.gooey_parser import GooeyParser diff --git a/gooey/_tmp/mockapp.py b/gooey/_tmp/mockapp.py index 0a4c791..61c07cf 100644 --- a/gooey/_tmp/mockapp.py +++ b/gooey/_tmp/mockapp.py @@ -13,7 +13,7 @@ import argparse as ap from argparse import ArgumentParser as AP from gooey import Gooey -from gooey.python_bindings.gooey_decorator import GooeyParser +from gooey import GooeyParser def main(): @@ -25,8 +25,8 @@ def main(): my_cool_parser = GooeyParser(description=desc) my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output", widget="FileChooser") # positional - # my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser') - my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser') + my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser') + # my_cool_parser.add_argument('-c', '--cron-schedule', default=10, 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') diff --git a/gooey/gui/widgets/widget_pack.py b/gooey/gui/widgets/widget_pack.py index 7f63e98..f7a942c 100644 --- a/gooey/gui/widgets/widget_pack.py +++ b/gooey/gui/widgets/widget_pack.py @@ -54,7 +54,10 @@ class BaseChooser(WidgetPack): return widget_sizer def getValue(self): - return self.text_box.GetValue() + if self.option_string: + return '{0} {1}'.format(self.option_string, self.text_box.GetValue()) + else: + return self.text_box.GetValue() def onButton(self, evt): raise NotImplementedError diff --git a/gooey/mockapplications/mockapp.py b/gooey/mockapplications/mockapp.py index 68fa9a9..fb44c28 100644 --- a/gooey/mockapplications/mockapp.py +++ b/gooey/mockapplications/mockapp.py @@ -13,7 +13,7 @@ import argparse as ap from argparse import ArgumentParser as AP from gooey import Gooey -from gooey.python_bindings.gooey_decorator import GooeyParser +from gooey import GooeyParser @Gooey @@ -26,8 +26,8 @@ def main(): my_cool_parser = GooeyParser(description=desc) my_cool_parser.add_argument("filename", help=file_help_msg, widget="FileChooser") # positional my_cool_parser.add_argument("outfile", help="Name of the file where you'll save the output", widget="FileChooser") # positional - # my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser') - my_cool_parser.add_argument('-c', '--cron-schedule', default=10, type=int, help='Set the datetime when the cron should begin', widget='DateChooser') + my_cool_parser.add_argument('-c', '--countdown', default=10, type=int, help='sets the time to count down from you see its quite simple!', widget='DateChooser') + # my_cool_parser.add_argument('-c', '--cron-schedule', default=10, 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') diff --git a/gooey/python_bindings/gooey_decorator.py b/gooey/python_bindings/gooey_decorator.py index 8692467..3062f16 100644 --- a/gooey/python_bindings/gooey_decorator.py +++ b/gooey/python_bindings/gooey_decorator.py @@ -154,42 +154,7 @@ def get_caller_path(): return tmp_sys.argv[0] -class GooeyParser(object): - def __init__(self, **kwargs): - self.__dict__['parser'] = ArgumentParser(**kwargs) - self.widgets = {} - @property - def _mutually_exclusive_groups(self): - return self.parser._mutually_exclusive_groups - - @property - def _actions(self): - return self.parser._actions - - @property - def description(self): - return self.parser.description - - def add_argument(self, *args, **kwargs): - widget = kwargs.pop('widget', None) - self.parser.add_argument(*args, **kwargs) - self.widgets[self.parser._actions[-1].dest] = widget - - def add_mutually_exclusive_group(self, **kwargs): - return self.parser.add_mutually_exclusive_group(**kwargs) - - def add_argument_group(self, *args, **kwargs): - return self.parser.add_argument_group(*args, **kwargs) - - def parse_args(self, args=None, namespace=None): - return self.parser.parse_args(args, namespace) - - def __getattr__(self, item): - return getattr(self.parser, item) - - def __setattr__(self, key, value): - return setattr(self.parser, key, value) if __name__ == '__main__': pass diff --git a/gooey/python_bindings/gooey_parser.py b/gooey/python_bindings/gooey_parser.py new file mode 100644 index 0000000..95e2b88 --- /dev/null +++ b/gooey/python_bindings/gooey_parser.py @@ -0,0 +1,40 @@ + +from argparse import ArgumentParser + + +class GooeyParser(object): + def __init__(self, **kwargs): + self.__dict__['parser'] = ArgumentParser(**kwargs) + self.widgets = {} + + @property + def _mutually_exclusive_groups(self): + return self.parser._mutually_exclusive_groups + + @property + def _actions(self): + return self.parser._actions + + @property + def description(self): + return self.parser.description + + def add_argument(self, *args, **kwargs): + widget = kwargs.pop('widget', None) + self.parser.add_argument(*args, **kwargs) + self.widgets[self.parser._actions[-1].dest] = widget + + def add_mutually_exclusive_group(self, **kwargs): + return self.parser.add_mutually_exclusive_group(**kwargs) + + def add_argument_group(self, *args, **kwargs): + return self.parser.add_argument_group(*args, **kwargs) + + def parse_args(self, args=None, namespace=None): + return self.parser.parse_args(args, namespace) + + def __getattr__(self, item): + return getattr(self.parser, item) + + def __setattr__(self, key, value): + return setattr(self.parser, key, value)