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

select dropdown changes capitalization when displaying choice values #247

Open
tomanizer opened this issue Jun 7, 2018 · 2 comments
Open

Comments

@tomanizer
Copy link

I specify a "choice" in my argparser, which Wooey properly displays as a select dropdown.
However, it unexpectedly changes the capitalization of the displayed values.

parser.add_argument("--currency", default="USD", choices=['USD', 'EUR', 'CHF' ,'JPY'], required=False)

In wooey this now becomes:

<select name="4-notecurrency-8" id="id_4-notecurrency-8">
  <option value="">----</option>
  <option value="USD" selected="">Usd</option>
  <option value="EUR">Eur</option>
  <option value="CHF">Chf</option>
  <option value="JPY">Jpy</option>
</select>

Note how capitalization of the choice options is changing.
This is unexpected. I did expect that the dropdown displayed values are exactly as specified.

The script still works, because internally it still used the capitalized versions as values. Only the display seems to be affected.

@Chris7
Copy link
Member

Chris7 commented Jun 7, 2018

That is because the display uses title on the choice values for display:

field_kwargs['choices'] = base_choices+[(str(i), str(i).title()) for i in choices]

I think most times it's more aesthetically pleasing to have title case but for abbreviations it's not a good thing. I'm open to suggestions on how to get the best of both worlds.

@tomanizer
Copy link
Author

citing from scripture
Zen of Python

"Explicit is better than implicit."

Wooey should not on it's own decide how to display values which were given by the user.
It should display them exactly as given - unless told to do otherwise.

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

No branches or pull requests

2 participants