File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -54,14 +54,24 @@ def textFromValue(self, v):
54
54
return t
55
55
56
56
def valueFromText (self , text ):
57
- return round (float (text ), self .decimals ())
57
+ clean = text
58
+ if self .prefix ():
59
+ clean = clean .split (self .prefix (), 1 )[- 1 ]
60
+ if self .suffix ():
61
+ clean = clean .rsplit (self .suffix (), 1 )[0 ]
62
+ return round (float (clean ), self .decimals ())
58
63
59
64
def validate (self , text , pos ):
65
+ clean = text
66
+ if self .prefix ():
67
+ clean = clean .split (self .prefix (), 1 )[- 1 ]
68
+ if self .suffix ():
69
+ clean = clean .rsplit (self .suffix (), 1 )[0 ]
60
70
try :
61
- float (text ) # faster than matching
71
+ float (clean ) # faster than matching
62
72
return QtGui .QValidator .Acceptable , text , pos
63
73
except ValueError :
64
- if re .fullmatch (_float_intermediate , text ):
74
+ if re .fullmatch (_float_intermediate , clean ):
65
75
return QtGui .QValidator .Intermediate , text , pos
66
76
return QtGui .QValidator .Invalid , text , pos
67
77
You can’t perform that action at this time.
0 commit comments