diff --git a/gooey/python_bindings/argparse_to_json.py b/gooey/python_bindings/argparse_to_json.py index 023a2eb..9676f73 100644 --- a/gooey/python_bindings/argparse_to_json.py +++ b/gooey/python_bindings/argparse_to_json.py @@ -256,6 +256,9 @@ def categorize(actions, widget_dict, options): elif is_standard(action): yield action_to_json(action, _get_widget(action, 'TextField'), options) + + elif is_file(action): + yield action_to_json(action, _get_widget(action, 'FileSaver'), options) elif is_choice(action): yield action_to_json(action, _get_widget(action, 'Dropdown'), options) @@ -274,7 +277,6 @@ def categorize(actions, widget_dict, options): def get_widget(widgets, action, default): supplied_widget = widgets.get(action.dest, None) - type_arg_widget = 'FileChooser' if action.type == argparse.FileType else None return supplied_widget or type_arg_widget or default @@ -319,6 +321,9 @@ def is_choice(action): ''' action with choices supplied ''' return action.choices +def is_file(action): + ''' action with FileType ''' + return isinstance(action.type, argparse.FileType) def is_standard(action): """ actions which are general "store" instructions. @@ -330,6 +335,7 @@ def is_standard(action): _StoreTrueAction ) return (not action.choices + and not isinstance(action.type, argparse.FileType) and not isinstance(action, _CountAction) and not isinstance(action, _HelpAction) and type(action) not in boolean_actions)