wooey / Wooey

A Django app that creates automatic web UIs for Python scripts.
http://wooey.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.12k stars 182 forks source link

select dropdown changes capitalization when displaying choice values #247

Open tomanizer opened 6 years ago

tomanizer commented 6 years ago

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 commented 6 years ago

That is because the display uses title on the choice values for display: https://github.com/wooey/Wooey/blob/e7024bddc5821de1bc89bc8f5ce3f5defaad2bca/wooey/forms/factory.py#L92

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 commented 6 years ago

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.