Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiFileChooser/MultiDirChooser don't handle list default values correctly #758

Open
8 tasks done
JozsefKutas opened this issue Oct 30, 2021 · 1 comment
Open
8 tasks done

Comments

@JozsefKutas
Copy link

JozsefKutas commented Oct 30, 2021

  • OS : Windows 10
  • Python Version : 3.9.6
  • Gooey Version : 1.0.8.1
  • Thorough description of problem
    • Expected Behavior
    • Actual Behavior

This is a seperate issue to the one I previously raised (#756), but it also concerns the handling of list default/initial values.

When paths are selected MultiFileChooser and MultiDirChooser, the selected paths are separated using the OS path separator in the input box. This concatenated string is split by formatter.multiFileChooser before being passed back to the client program, so the client program receives a list of paths. If a list of paths is used as a default value/initial value for the field, then I'd expect the inverse transformation to be applied: the paths should be joined by the OS path separator.

At the moment, argparse_to_json.textinput_with_nargs_and_list_default only handles vanilla text inputs, and so the default list of paths is shown as a list in the input box. If the value isn't changed, it is passed back to the program as a singleton list with the only element being a stringified list of paths.

  • A minimal code example -- preferably copy/pastable in the issue itself (less time figuring out how to run your code == more time debugging!)
from gooey import Gooey, GooeyParser


@Gooey
def main():
    parser = GooeyParser(description='Test')
    parser.add_argument('multi_file_choice', nargs='+', default=['a.txt', 'b.txt'],
                        widget='MultiFileChooser')
    args = parser.parse_args()
    print(args.multi_file_choice)


main()
  • Screenshot (if visual quirk)

image

image

@ChenglongMa
Copy link

Using 'initial_value' can solve this problem.

gooey_options={
  'initial_value': os.getcwd(),
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants