mirror of https://github.com/chriskiehl/Gooey.git
Browse Source
Moved GooeyParser into its own module and added it to __init__ imports; Fixed bug in widget_pack that was feeding incorrect value
pull/61/head
Moved GooeyParser into its own module and added it to __init__ imports; Fixed bug in widget_pack that was feeding incorrect value
pull/61/head
chriskiehl
10 years ago
6 changed files with 51 additions and 42 deletions
Unified View
Diff Options
-
1gooey/__init__.py
-
6gooey/_tmp/mockapp.py
-
5gooey/gui/widgets/widget_pack.py
-
6gooey/mockapplications/mockapp.py
-
35gooey/python_bindings/gooey_decorator.py
-
40gooey/python_bindings/gooey_parser.py
@ -1 +1,2 @@ |
|||||
from gooey.python_bindings.gooey_decorator import Gooey |
from gooey.python_bindings.gooey_decorator import Gooey |
||||
|
from gooey.python_bindings.gooey_parser import GooeyParser |
@ -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) |
Write
Preview
Loading…
Cancel
Save