-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Andy managed to define the rules for converting string to float:
#3499 (review)
http://linuxcnc.org/docs/devel/html/gui/gui-dev-reference.html#_localization_of_float_numbers_in_guis
These rules are based on long discussions and problems with float localization integration.
It follows from these rules that the locale.atof() function should not be used.
At the same time, @c-morley is working on common libraries for GUIs.
https://github.com/LinuxCNC/linuxcnc/tree/master/lib/python/common
I would like to ask him if he would make a common replacement for the local.atof function.
Can be based on the fix created by Sigma1912
#3500
The function should contain:
- Removing spaces from the initial string
- replacing (,) with (.)
string_to_float = string_to_float.replace(",", ".") - converting string to float
- the whole thing should be enclosed in a Try ... except function
In case the string contains letters or multiple decimal separators.
For my own needs I could write something like that. But I can't write a shared library that should appear in many places in many GUIs. I don't have that much experience.