Hi All,
I wrote a custom Integer validator which basically allows user to
add "%" at the end.
When user enters certain integer value with combination "%" i have to strip
and validate.
but its giving following error:
QIntValidator::validate: Second tuple element is not convertible to
unicode???????
can any one tell me what is wrong with the following code:
class LineEditValidator(QtGui.QIntValidator):
def __init__(self,minimum,maximum,parent=None):
QtGui.QIntValidator.__init__(self,minimum,maximum,parent)
def validate(self,inputVal,pos):
inputVal=str(inputVal)
if inputVal=="":
return QtGui.QValidator.Invalid,inputVal,pos
if inputVal.endswith("%"):
try:
inputVal=inputVal.rstrip("%")
inputVal=int(inputVal)
except Exception,msg:
return QtGui.QValidator.Invalid,inputVal,pos
try:
inputVal=int(inputVal)
except:
return QtGui.QValidator.Invalid,inputVal,pos
if inputVal >=self.bottom() and inputVal <=self.top():
return QtGui.QValidator.Acceptable,inputVal,pos
else:
return QtGui.QValidator.Invalid,inputVal,pos
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside