Skip to content

Gmoccapy: value checks on table entries - #4559

Open
Sigma1912 wants to merge 3 commits into
LinuxCNC:masterfrom
Sigma1912:gmoccapy_table-entry-value-checks
Open

Sigma1912 wants to merge 3 commits into
LinuxCNC:masterfrom
Sigma1912:gmoccapy_table-entry-value-checks

Conversation

@Sigma1912

@Sigma1912 Sigma1912 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Successor for #4436

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'
@Sigma1912 Sigma1912 changed the title Gmoccapy table entry value checks Gmoccapy: value checks on table entries Sep 17, 2026
Comment on lines +167 to +171
value = float(self.entry.get_text())
if self.integer_only:
if value != int(value):
raise ValueError
value = int(value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You remove the use_localization here. But, if it is set and the value is "1,0" in a locale that uses a comma as separator, then the new construct works differently by failing. That is, of course, unless you can guarantee that the get_text() never returns a localized version of the numeric value.

If you cannot guarantee that, then I think you first need to get the value as a float, like the original conversions did, and then do the comparison if value != int(value) if integer_only is requested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hansu
I put it back in. This is here to maintain compatibility with gscreen.
If it were my choice I would remove all localization but we are unfortunately obliged to drag some legacy code along.

- 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
@Sigma1912
Sigma1912 force-pushed the gmoccapy_table-entry-value-checks branch from cb81188 to fcad9fd Compare September 17, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants