-
-
Notifications
You must be signed in to change notification settings - Fork 669
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
[widget Audit] toga.NumberInput #1946
Conversation
f172ab4
to
e51b811
Compare
e51b811
to
1986e79
Compare
It doesn't look like #1455 has been fixed on Cocoa. After clicking Clear followed by the decrement button: |
Co-authored-by: Malcolm Smith <smith@chaquo.com>
…actored common implementations.
Fixed (Again). |
# ROUND_DOWN would not be unreasonable for manually-entered strings, but it | ||
# interacts badly with native increment operations that use floats. For example, | ||
# 1.2 might be incremented to 1.299999997, and then rounded back down to 1.2, | ||
# so nothing would change. |
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.
Good point - but I guess my question is why HALF_UP rather than HALF_DOWN? I guess it doesn't really matter, as it's literally only the 1.500000000 case that matters - but HALF_DOWN would seem more consistent with the ROUND_DOWN in that case.
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.
This only makes a difference when the app user manually enters a number that ends with a 5, so we should do whatever will confuse the smallest number of those users, who are likely not to have any advanced mathematics education.
ROUND_HALF_DOWN is not commonly used by anyone, so the real choice is between ROUND_HALF_UP (which I was taught in school), and ROUND_HALF_EVEN (which @freakboy3742 was taught in school).
ROUND_HALF_EVEN is used by the Python round
function, and in most scientific contexts.
ROUND_HALF_UP is used by spreadsheets, and, based on my searches, in the majority of basic mathematics education, at least in English. For example, see "as taught in school" in the AppleScript documentation.
So I think we should go with ROUND_HALF_UP.
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.
That reasoning all makes sense to me. (also - lol at AppleScript having an actual "as taught in school" keyword....)
self.interface.on_change(None) | ||
validate = getattr(self.interface, "_validate", None) | ||
if validate: | ||
validate() |
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.
This seems like it should be managed by subclassing, rather than probing attribute access.
Audit of the Numberinput widget.
Builds on #1944.
Notable implementation details:
Fixes #1455
Fixes #1234
Audit checklist