Solved myself  for string i was passing int

On Wed, Oct 5, 2011 at 1:12 PM, Ravi ..........! <hi5frei...@gmail.com>wrote:

> 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
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Reply via email to