Просмотр исходного кода

- fixed an error in the FCDoubleSpinner class when FlatCAM is run on system with locale that use the comma as decimal separator

Marius Stanciu 6 лет назад
Родитель
Сommit
c2c275e9ed
2 измененных файлов с 23 добавлено и 2 удалено
  1. 4 0
      README.md
  2. 19 2
      flatcamGUI/GUIElements.py

+ 4 - 0
README.md

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
 
 
 =================================================
 =================================================
 
 
+26.10.2019
+
+- fixed an error in the FCDoubleSpinner class when FlatCAM is run on system with locale that use the comma as decimal separator
+
 25.10.2019
 25.10.2019
 
 
 - QRCode Tool: added ability to add negative QRCodes (perhaps they can be isolated on copper?); added a clear area surrounding the QRCode in case it is dropped on a copper pour (region); fixed the Gerber export
 - QRCode Tool: added ability to add negative QRCodes (perhaps they can be isolated on copper?); added a clear area surrounding the QRCode in case it is dropped on a copper pour (region); fixed the Gerber export

+ 19 - 2
flatcamGUI/GUIElements.py

@@ -632,9 +632,10 @@ class FCDoubleSpinner(QtWidgets.QDoubleSpinBox):
         return ret_val
         return ret_val
 
 
     def validate(self, p_str, p_int):
     def validate(self, p_str, p_int):
+        text = p_str.replace(',', '.')
         try:
         try:
-            if float(p_str) < self.minimum() or float(p_str) > self.maximum():
-                return QtGui.QValidator.Intermediate, p_str, p_int
+            if float(text) < self.minimum() or float(text) > self.maximum():
+                return QtGui.QValidator.Intermediate, text, p_int
         except ValueError:
         except ValueError:
             pass
             pass
         return QtGui.QValidator.Acceptable, p_str, p_int
         return QtGui.QValidator.Acceptable, p_str, p_int
@@ -2161,3 +2162,19 @@ class MyCompleter(QCompleter):
 
 
     def getSelected(self):
     def getSelected(self):
         return self.lastSelected
         return self.lastSelected
+
+
+def rreplace(s, old, new, occurrence):
+    """
+    Credits go here:
+    https://stackoverflow.com/questions/2556108/rreplace-how-to-replace-the-last-occurrence-of-an-expression-in-a-string
+
+    :param s: string to be processed
+    :param old: old char to be replaced
+    :param new: new char to replace the old one
+    :param occurrence: how many places from end to replace the old char
+    :return: modified string
+    """
+
+    li = s.rsplit(old, occurrence)
+    return new.join(li)