-
Notifications
You must be signed in to change notification settings - Fork 1.2k
tooledit_widget - decimal point = dot #3086
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
Conversation
hansu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| else: | ||
| try: | ||
| array[offset]= locale.format_string("%10.4f", float(word.lstrip(i))) | ||
| array[offset]= locale.delocalize(locale.format_string("%10.4f", float(word.lstrip(i)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
locale.delocalize(locale.format_string()) is a bit ... hmm ... twofold.
First add the proper locale format and then remove it?
A better style would be to use simply the string format function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can string format solve problems with , and . ?
In CS localization it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but if we want the tooltable always show dots, we don't need localization at this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but we need decimal point "comma" akceptable for DE and CS and other localization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that folks have dumped particular platforms for less of a reason than for not allowing them to regularly use their number pad.
|
I tested this PR with this localizations: cs localization - it works So I started using pure branche 2.9 I focused only on the DRO problem and the result is the same: I want to ask you for a test: |
For de_DE: 1,5 results in 1.5 and 1.5 in 15. IMHO 1,5 and 1.5 should be read as 1.5 like some CAD systems do. |
|
Thank you for results of my test.
I think, this is source of problem. 1,5 and 1.5 should not be read as 1.5. For CS localization 1,5 and 1.5 is 1.5 and this PR works. This PR only shows deeper problem. What is your view on this problem? |
I think this is just a nice to have.
This I might implement |
This help me. |
|
I think you have come to a reasonable practical solution. Should we not use this thread to quickly sketch what an ideal solution would like like? |
|
If you would be willing to help, I would be very happy. I understand that this is not Hans' priority. Python, on the other hand, is my nemesis. The current status is as follows:
This is a long run for me. |
:) I cannot help with coding for any foreseeable future, but let us have a look at what we want.
I am not sure if he disagrees. In my mind any field that is expecting a number should not accept anything that it does not want to parse because of non-numerical characters or "ungrammatical" use of a thousands/decimal separator. So, "1.5" IMHO should not have been accepted in a German localisation.
That is already all very operational. Those comma/decimal separators are confusing everyone everywhere. And we have the extra difficulty that the CNC folks may be expecting their beloved "." decimal operator even when everything is entered with "," because of the numerical keypad offering it that way. G code for instance only uses the point, right? So, I think I would have a rule like, every number is entered the exact same way (and only that way) it is displayed. Character strings that not producing the same number as displayed (after transitioning to float and back to char) are not valid numbers and should not be accepted but trigger a beep or so. Ideally, the active localization should somehow be shown in the window accepting the values. |
|
Reading float with comma is Norbert's request. |
|
I made some research: locale_format.py Results: I already know why 1.5 = 15 for DE localization. The problem is not in locale.format_string Now I know why this PR is causing problems. I changed the decimal point for the source of locale.atof. I don't know how to solve it at the moment. The solution can be more:
|
|
[zz912]
I already know why 1.5 = 15 for DE localization.
It just doesn't read dots, so:
1.523 = 1523
2.4586 = 24586
Actually, the de_DE locale consider dots the thousands separator, and
ignore them in numbers. See this block in/usr/share/i18n/locales/de_DE:
LC_NUMERIC
decimal_point ","
thousands_sep "."
grouping 3
END LC_NUMERIC
For cs_CZ, the same block look like this:
LC_NUMERIC
decimal_point ","
thousands_sep " "
grouping 3
END LC_NUMERIC
You would get the same effect with cs_CZ when using non-breaking space
in the number, ie "1 523" = 1523.
…--
Happy hacking
Petter Reinholdtsen
|
|
Thanks everyone for the comments. |
|
Looks good to me 👍 . |
How should I do it? |
Previously: tooledit_widget displayed float numbers with decimal dot for localizations that use decimal dot tooledit_widget displayed float numbers with decimal comma for localizations that use decimal comma Now: tooledit_widget displays float numbers with a decimal dot for all localizations The functionality is preserved, when it is possible to enter a float with both a comma and a dot for localizations with a decimal comma Reason for change: Gmoccapy displayed some numbers with a decimal dot and some numbers with a decimal comma. This is a unification. More here: LinuxCNC#2966 (comment)
|
I have done it now for you.
pick 3bc36a8456 tooledit_widget - decimal point = dot
- pick 353a76b62f Update tooledit_widget.py
+ s 353a76b62f Update tooledit_widget.py
# Rebase f7cbbcce36..353a76b62f onto f7cbbcce36 (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
|
|
We have the option to "squash and merge" when merging a PR, but it's neater (and preserves better descriptions) if you do it yourself. |
|
The next question is... should it go in 2.9 instead? Is it a bugfix? It's one of those grey-areas, to me. |
|
Not really a bugfix. It is more about to normalize the dots and commas. |
Exist way in web github? I dont use git. |
That one Andy mentioned, but that can be only done by the person who merges it. |



Previously:
tooledit_widget displayed float numbers with decimal dot for localizations that use decimal dot tooledit_widget displayed float numbers with decimal comma for localizations that use decimal comma
Now:
tooledit_widget displays float numbers with a decimal dot for all localizations
The functionality is preserved, when it is possible to enter a float with both a comma and a dot for localizations with a decimal comma
Reason for change:
Gmoccapy displayed some numbers with a decimal dot and some numbers with a decimal comma. This is a unification. More here: #2966 (comment)