- updated the GUI fields for the Scale and Offset in the Object UI to allow only numeric values and operators in the list [/,*,+,-], spaces, dots and comma

This commit is contained in:
Marius Stanciu 2020-05-25 03:37:34 +03:00 committed by Marius
parent 84ffa68cb0
commit 5f81d415a0
4 changed files with 20 additions and 3 deletions

View File

@ -667,6 +667,19 @@ class NumericalEvalEntry(EvalEntry):
validator = QtGui.QRegExpValidator(regex, self)
self.setValidator(validator)
class NumericalEvalTupleEntry(EvalEntry):
"""
Will evaluate the input and return a value. Accepts only float numbers and formulas using the operators: /,*,+,-,%
"""
def __init__(self):
super().__init__()
regex = QtCore.QRegExp("[0-9\/\*\+\-\%\.\s\,]*")
validator = QtGui.QRegExpValidator(regex, self)
self.setValidator(validator)
class FCSpinner(QtWidgets.QSpinBox):
returnPressed = QtCore.pyqtSignal()

View File

@ -114,7 +114,7 @@ class ObjectUI(QtWidgets.QWidget):
self.common_grid.addWidget(self.transform_label, 2, 0, 1, 2)
# ### Scale ####
self.scale_entry = FCEntry()
self.scale_entry = NumericalEvalEntry()
self.scale_entry.set_value(1.0)
self.scale_entry.setToolTip(
_("Factor by which to multiply\n"
@ -132,7 +132,7 @@ class ObjectUI(QtWidgets.QWidget):
self.common_grid.addWidget(self.scale_button, 3, 1)
# ### Offset ####
self.offsetvector_entry = EvalEntry2()
self.offsetvector_entry = NumericalEvalTupleEntry()
self.offsetvector_entry.setText("(0.0, 0.0)")
self.offsetvector_entry.setToolTip(
_("Amount by which to move the object\n"

View File

@ -252,7 +252,7 @@ class FlatCAMObj(QtCore.QObject):
def on_scale_button_click(self):
self.read_form()
try:
factor = float(eval(self.ui.scale_entry.get_value()))
factor = float(self.ui.scale_entry.get_value())
except Exception as e:
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Scaling could not be executed."))
log.debug("FlatCAMObj.on_scale_button_click() -- %s" % str(e))

View File

@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
=================================================
25.05.2020
- updated the GUI fields for the Scale and Offset in the Object UI to allow only numeric values and operators in the list [/,*,+,-], spaces, dots and comma
24.05.2020
- changes some icons