From 3d7ec410f248b26702ef0b1519e36734da3164e8 Mon Sep 17 00:00:00 2001 From: cvw Date: Mon, 17 Jun 2013 14:49:25 +0000 Subject: [PATCH] best warning on qlineedit for double value --- .../MGCleanerPlug/MGCleanerMonPlugDialog.py | 28 +++++++++++++++++-- .../MGCleanerPlug/MGCleanerPlugDialog.ui | 6 ++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py index 9b729c52d..6511268a8 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py +++ b/src/Tools/MGCleanerPlug/MGCleanerMonPlugDialog.py @@ -78,24 +78,28 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget): #v1.setTop(10000.) v1.setDecimals(4) self.SP_MinHoleSize.setValidator(v1) + self.SP_MinHoleSize.titleForWarning="MinHoleSize" v2=QDoubleValidator(self) v2.setBottom(0.) #v2.setTop(10000.) v2.setDecimals(4) self.SP_ToleranceDisplacement.setValidator(v2) + self.SP_ToleranceDisplacement.titleForWarning="ToleranceDisplacement" v3=QDoubleValidator(self) v3.setBottom(0.) #v3.setTop(10000.) v3.setDecimals(4) self.SP_ResolutionLength.setValidator(v3) + self.SP_ResolutionLength.titleForWarning="ResolutionLength" v4=QDoubleValidator(self) v4.setBottom(0.) #v4.setTop(10000.) v4.setDecimals(4) self.SP_OverlapDistance.setValidator(v4) + self.SP_OverlapDistance.titleForWarning="OverlapDistance" self.resize(800, 500) self.clean() @@ -253,12 +257,30 @@ class MGCleanerMonPlugDialog(Ui_MGCleanerPlugDialog,QWidget): """ def SP_toStr(self, widget): + """only for a QLineEdit widget""" #cr, pos=widget.validator().validate(res, 0) #n.b. "1,3" is acceptable !locale! try: - return str(float(widget.text())) + val=float(widget.text()) except: - widget.setProperty("text", "0.0") - return "0.0" + QMessageBox.warning(self, widget.titleForWarning, "float value is incorrect: '"+widget.text()+"'") + res=str(widget.validator().bottom()) + widget.setProperty("text", res) + return res + valtest=widget.validator().bottom() + if valtest!=None: + if valvaltest: + QMessageBox.warning(self, widget.titleForWarning, "float value is over maximum: "+str(val)+" > "+str(valtest)) + res=str(valtest) + widget.setProperty("text", res) + return res + return str(val) def getResumeData(self, separator="\n"): text="" diff --git a/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui b/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui index 6c0925a7f..5e3ddbfba 100644 --- a/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui +++ b/src/Tools/MGCleanerPlug/MGCleanerPlugDialog.ui @@ -558,13 +558,13 @@ Default is computed from model. - 360 + 90 0 - 0.01 + 1 15 @@ -652,7 +652,7 @@ Default is computed from model. - 360 + 90 0 -- 2.39.2