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

Can only access first line of input in Textarea widget #499

Closed
nklapste opened this issue Nov 6, 2019 · 1 comment
Closed

Can only access first line of input in Textarea widget #499

nklapste opened this issue Nov 6, 2019 · 1 comment

Comments

@nklapste
Copy link

nklapste commented Nov 6, 2019

OS: Windows 10

Python Version: Python 3.6.3

Gooey Version: 1.0.3

Expected Behavior: When using a Textarea widget all lines of a multi-line input is accessible from the parsed argparse.Namespace object.

Actual Behavior: When using a Textarea widget only the first line of a multi-line input is accessible from the parsed argparse.Namespace object.

Example Code:
The below code yields a gooey GUI with a Textarea input with "hello" as the first line and "there" as the second line of default input. Clicking Start however, results in a error as the second assert fails.

from gooey import GooeyParser, Gooey


def get_parser() -> GooeyParser:
   parser = GooeyParser()
   parser.add_argument(
       "--text-area",
       default="hello\nthere",
       dest="text_area",
       widget="Textarea",
   )
   return parser


@Gooey
def main():
   args = get_parser().parse_args()
   assert args.text_area == "hello"  # this passes (actual | not expected)
   assert args.text_area == "hello\nthere"  # this fails (expected)


if __name__ == "__main__":
   main()

Other:
Only multi-line text (delimited by newline \n characters) suffers this issue. Text that is long enough to be wrapped to the next line (but is not actually delimited by a newline \n) is still accessible from the parsed argparse.Namespace object.

@jmgrenier
Copy link

I had the same issue with the same system specs. I looked into it, and turns out it's caused by the way Windows' cmd parses the command fed by Gooey, which doesn't handle very well newline characters (or any escape characters, for that regard).

An easy fix to this is passing requires_shell=False to Gooey's decorator. This will treat newline characters as they should.

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

3 participants