Re: Problem with string -> int conversion ?



Madhusudan Singh wrote:

> I am working with an application that I designed with the Designer > pyuic
> workflow and I get the following error on trying to process the contents
> of
> a combobox :
>
> Traceback (most recent call last):
> File "measure.py", line 908, in acquiredata
> np=self.getNPrange()
> File "measure.py", line 1167, in getNPrange
> signalrange=int(signalrangestr)
> TypeError: int() argument must be a string or a number
>
> The code is :
>
> void Form3::getNPrange()
> {

what language is this?

> signalrangestr=self.NPcombobox.currentText()
> signalrange=int(signalrangestr)
> if globaldebug : print 'NP Signal range = ',signalrange
> return signalrange
> }

> Isn't signalrangestr above a string ? Or at the very least, a number.

if the callback code is Python, you should be able to add a print
statement to the line just before the failing "int" call:

print repr(signalrangestr), type(signalrangestr)
signalrange = int(signalrangestr)

that print statement should be all you need to figure out what
signalrangestr really is.

</F>



.



Relevant Pages

  • Problem with string -> int conversion ?
    ... I am working with an application that I designed with the Designer> pyuic ... intargument must be a string or a number ... return signalrange ... AttributeError: strip ...
    (comp.lang.python)
  • Re: Problem with string -> int conversion ?
    ... >> if the callback code is Python, you should be able to add a print ... >> signalrange = int ... googling for "pyqt qstring" brought up this page: ...
    (comp.lang.python)