'int' object is not callable in an threaded app

Hamilton, William whamil1 at entergy.com
Tue May 22 11:35:07 EDT 2007


> From: king kikapu
> 
> Hi,
> 
> i have a problem with the following piece of code that id just drive
> me nuts (from the morning...)
> I think is more Python specific than Qt, folks from Qt forum have
> already give me directions of how to do it but that Python error
> message is just impossible for me to figure out. And i am sure that it
> something just under my nose...
> 
> So, i have a form with 2 spin boxes, a button and a progress bar. When
> i hit the button i expect to see the progressbar filled with the
> values of spFrom and spTo (the 2 spinboxes)
> 
> I was given help if how to setup correctly the Signals and Slots
> mechanism but i am stuck at this Python error at the "worker.start()"
> command:
> 
> TypeError: 'int' object is not callable
> 
> 
> Before i go and suicide, has anybody an idea what is going on
> here ??...
> 
> 
> 
> import sys
> from PyQt4 import QtCore, QtGui
> from calculatorform_ui import Ui_CalculatorForm
> from ui_countNumbers import Ui_MainWindow
> from time import sleep
> 
> class WorkerThread(QtCore.QThread):
>     def __init__(self, start, end):
>         QtCore.QThread.__init__(self)
>         self.start = start
>         self.end = end
> 
>     def run(self):
>         for x in range(start, end):
>             self.emit(QtCore.SIGNAL("updateProgress"), x)
> 
> 
> class CountNumbersForm(QtGui.QMainWindow):
>     def __init__(self, parent=None):
>         QtGui.QMainWindow.__init__(self, parent)
>         self.ui = Ui_MainWindow()
>         self.ui.setupUi(self)
> 
>     @QtCore.pyqtSignature("")
>     def on_start_clicked(self):
>         worker.start()
> 
>     def updateProgress(self, val):
>         self.ui.progres.setValue(val)
> 
> 
> if __name__ == "__main__":
>     app = QtGui.QApplication(sys.argv)
>     count = CountNumbersForm();
>     worker = WorkerThread(count.ui.spFrom.value(),
> count.ui.spTo.value() + 1);
>     QtCore.QObject.connect(worker, QtCore.SIGNAL("updateProgress"),
> count.updateProgress, QtCore.Qt.QueuedConnection)
>     count.show()
>     sys.exit(app.exec_())



It appears that worker.start gets set to the result of
count.ui.spFrom.value().  If that result is an int, then worker.start() is
going to generate the TypeError you received.  Did you actually mean to call
worker.run() instead?


---
-Bill Hamilton



More information about the Python-list mailing list