Conversation
|
That was quick, thanks. I haven't dug deep into this but I wonder if we should fix it better in tooledit (or additionally). linuxcnc/lib/python/gladevcp/tooledit_widget.py Lines 513 to 523 in bae5676 This would also fix it in this case. But it might be bad if this function gets accidentally a float value which is cut then. |
b1369d0 to
bb1801a
Compare
|
I noticed that the pocket number column currently allows negative integer values, which I don't think is correct? |
I don't know. Maybe one want to disable a tool by setting pocket to -1? |
|
I use duplicate pocket numbers, stacked tools |
|
Just checked in Axis gui (if that is anything to go by):
And yes, there is definitely a use for duplicate pocket number. |
|
Okay, but duplicated tool numbers? You would never know which one will be used. |
Yes, those should indeed not be allowed. |
|
I used programs where the tool ID has to be unique, it is tricky to do it without getting in the way when the user is renumbering tools for whatever reason, some thought need be put into that. Although at the final state there should be no duplicates, when user is wanting to do a renumbering, not having any hard blocks (current behavior) allows to have a moment where there are two tools with the same number; the trick is finding a reasonable way to allow renumbering without getting in the way of the renumbering cleanup flow, some kind of message confirmation, same number already in the table, want to swap number? cancel? |
| except: | ||
| pass | ||
| # validate input for orientation: check if int and valid range | ||
| elif col == 15: |
There was a problem hiding this comment.
This did not get the same float-tolerant treatment: it still uses plain int(new_text). Direct cell entry of 3.0 is now accepted for tool/pocket but still silently rejected for orientation. Same int(float(...)) pattern, keeping the existing range check, would unify it.
There was a problem hiding this comment.
What are the lines you are referring to? I think the above lines not.
There was a problem hiding this comment.
GitHub displays it weird because is not in the diff
I could imagine to do the check on save. So it's easy to rename the IDs and have duplicate IDs in between. |
|
Generally I cannot really comment since I don't use the tool table much. Check on save seems the most straight forward to me but we would probably also have to check on load since a tool table can easily be edited outside the gui.
I thought this was only shared by gscreen. |
|
As a tester, I don't think silently truncating a decimal value is the right behavior here. If the Tool Number or Pocket Number field expects an integer and a user accidentally enters, for example, From a testing/UX perspective, silently modifying the user's input can hide an input error and potentially lead to a different tool or pocket being used than the operator intended. In my opinion, it would be safer and clearer to reject the value and tell the user that an integer is required. The user can then correct the input explicitly. |
733754b to
361bc09
Compare
|
I agree that silent changes to the values entered is not the right thing to do so I made some deeper changes.
Testers welcome. |
| return None | ||
| if self.use_localization: | ||
| try: | ||
| value = locale.atof( value ) |
There was a problem hiding this comment.
Just a small reminder regarding the use of locale.atof() — perhaps it simply got overlooked in the context of the other changes. 🙂
We have spent quite a bit of time dealing with atof() and decimal separator localization in LCNC, and we even have a recommendation about this in the documentation: https://linuxcnc.org/docs/devel/html/en/gui/gui-dev-reference.html#_localization_of_float_numbers_in_guis
atof() can of course work correctly in some situations, but in combination with locales I find it rather tricky and potentially a bit of a time bomb — especially because the problem may not show up under the usual EN locale.
If the intention here is to keep using locale.atof(), I would at least ask for it to be tested with the DE locale, where the decimal separator is a comma. That is where I would expect any potential problems to show up first.
Please don't take this as a blocker for the change, but rather as a reminder based on the experience we've already had with this in LCNC.
There was a problem hiding this comment.
That is current code that got moved around not something new. That is there for backwards compatibility aimed at Gscreen only not something that Gmoccapy uses.
There was a problem hiding this comment.
Yes, I understand that this is existing code being moved around and that it is only there for Gscreen backwards compatibility.
The reason I mentioned it is precisely because this is how we ended up with problems in the past. atof() had been working without any apparent issues for a long time, and then some surrounding code changed and suddenly the locale-related problems started showing up.
So my concern is not that atof() is being introduced here as something new, but rather that moving it around can potentially change the context in which it runs. That's why I would still consider a quick test with the DE locale worthwhile, just to make sure the existing behaviour remains safe after the change.
If that has already been covered by the existing Gscreen compatibility testing, then of course that's fine.
361bc09 to
4265bc8
Compare
4265bc8 to
a27dfc9
Compare
a27dfc9 to
4a9e629
Compare
4a9e629 to
4eac6cc
Compare
Both implemented. |
Could you elaborate on the reasoning behind this?
Possibly, but why? The point is that the recipient widget verifies and displays the message as to why the entry was rejected. |
First it messes up the order. Ok no big thing.
Because the Gmoccapy dialogs are touch optimized. And contribute to a consistent UI. For the exit of the tool table there is also the Gmoccapy dialog used. |
Clicking on the header 'Tool#' will sort the table.
But in that case '61' would also not help, you would have to change the tool number either way.
The problem is that there might already be a tool '0' in the table. Also tool number '0' has different usage depending on random/non-random tool changers. |
Ok, I'll have a look. |
8ffb330 to
1e404c6
Compare
ef085c4 to
2223d77
Compare
|
Fixed the bug where an entry with a zero decimal (eg '16.0') in the calculator did not trigger an error. Modified as requested:
|
That is a valid usecase. I can imagine similar cases for some tools. |
👍
👍
|
2223d77 to
b488664
Compare
hansu
left a comment
There was a problem hiding this comment.
And please rebase to master to resolve the conflicts.
| if value != int(value): | ||
| raise ValueError | ||
| value = int(value) | ||
| if self.use_localization: |
There was a problem hiding this comment.
locale.atof( value ) doesn't make sense here because localization is already handled in compute() and value is already a float at this point (for non integer mode).
There was a problem hiding this comment.
Git messed up the line numbers again, it is about this part
value = float(self.entry.get_text())
if self.integer_only:
if value != int(value):
raise ValueError
value = int(value)
if self.use_localization:
value = locale.atof( value )| qualified = '' | ||
| temp = self.eval_string.strip( " " ).replace("Pi", "math.pi") | ||
| if self.integer_only and ( '.' in temp or ',' in temp): | ||
| self.entry.set_text( "Error" ) |
There was a problem hiding this comment.
What speaks against raising the ValueError right here instead of later in get_value()?
There was a problem hiding this comment.
Its about those lines:
def compute( self ):
qualified = ''
temp = self.eval_string.strip( " " ).replace("Pi", "math.pi")
if self.integer_only and ( '.' in temp or ',' in temp):
self.entry.set_text( "Error" )
returnThere was a problem hiding this comment.
The check for decimal symbols in compute() is required to disallow keyboard entry of, say, '6.0' in the calculator, which we disallow for direct keyboard entries into the table.
The check in get_value() is required to check the calculator result of 'b = str( eval( qualified ) )' because a user can enter an operation using integers into the calculator using the keyboard (eg '6/2' is allowed but '3/2' must raise an error).
| value = float(new_text) | ||
| if value != int(value) or value not in range(10): |
There was a problem hiding this comment.
Why not
try :
value = int(new_text)like above?
If we want to accept inputs like this "1.000000" we could also use <float_type>.is_integer()
It is only a bit inaccurate:
>>> float("1.000000000000001").is_integer()
False
>>> float("1.0000000000000001").is_integer()
TrueThere was a problem hiding this comment.
I'll adopt the first suggestion to make it consistent with the code for columns 1 and 2.
I think we agreed that we don't want to silently change floats to integers and I have already changed the calculator widget to not accept keyboard input containing decimals.
Lines containing whitespace only are skipped rather than creating a new line with all '0' A message is shown on startup if - duplicate tool numbers have been found in the tool table - orientation is not in range 0...9 - a line is malformed, these are saved to a separate file so they are not silently deleted on save
The tool number for a new tool is preset to one above the highest nummber found in the table instead of '0'
- value validation is done by the widgets the values are entered for - if the calculator is set to 'integer_only' it will reject any value or expression containing '.' or ',' - value editing is handled in the widget regardless whether directly with the keyboard or the calculator - On save the table is checked for duplicate tool numbers
b488664 to
4c5e603
Compare
|
Alas, there have been other changes pushed directly that actually break this PR. I don't have the time right now so I'm afraid this will have to wait. |
|
After the rebase I get this: The two calls def tooltable_dialog(self, message, header=None):
if header is None:
header = _("Tool page error:")
self.dialogs.warning_dialog(self, header, message) def offsetpage_dialog(self, message, header=None):
if header is None:
header = _("Offset page error:")
self.dialogs.warning_dialog(self, header, message)should probably be |
It seems Chris did some commits on master accidentally :/ |
|
I'm sorry, couldn't recover. See new #4559 |
You could have force-pushed your new branch into this one, then this PR would have stayed alive. |


Discussion has shown that silent manipulation to make the user entered data fit the data type required by the cell is not wanted and that a rejected value should trigger a message to the user.
Value entries by the user to the offset or tool tables are currently 'verified' and manipulated in several places:
This PR moves value verification to the end recipient (ie the tooledit - and offsetpage widgets). The value is verified in the same place regardless whether the user uses the keyboard directly, the buttons in the calculator widget or the keyboard in the calculator widget. The cell and it's data range is known and a clear user message can be generated.
Fixes #4435
Also in this commit:
The second commit:
The third commit:
A message is shown on startup if the tool file contains
Example:
