Qt and progressBar - how to update

Robert Kern robert.kern at gmail.com
Sun May 16 14:52:17 EDT 2010


On 2010-05-16 13:28 , OMS wrote:
> I am quite new to Python and Qt and need very urgently advice on how
> to update Qt progressBar while executing a process. I have went thrugh
> number of 'google' stuff and saw different solution, hence none worked
> for me. The best idea I have seen is the usage of QThread and emiting
> signal from thread to MainWindow. I do not know however why the code I
> have written is not working. Most likely a stupid 'beginner related'
> error but as far as I am beginner I can't get it. There is a code
> below:
>
> #!/opt/local/bin/python2.6
>
> import os
> import sys
> import time
> from PyQt4 import QtCore
> from PyQt4 import QtGui
>
> from uiTest import Ui_MainWindow
>
> class MainWindow(QtGui.QMainWindow):
>      def __init__(self):
>          QtGui.QMainWindow.__init__(self)
>          self.ui=Ui_MainWindow()
>          self.ui.setupUi(self)
>          self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"),
> self.runWorker)
>
>      def runWorker(self):
>          self.worker = Worker()
>          self.connect(self.worker, QtCore.SIGNAL("progressUpdated"),
> self.updateWorkerProgress)
>          self.worker.start()
>
>      def updateWorkerProgress(self, min, max, progress):
>          self.ui.progressBar.setMinimum = min
>          self.ui.progressBar.setMaximum = max
>          self.ui.progressBar.setValue = progress

These should be

self.ui.progressBar.setMinimum(min)
self.ui.progressBar.setMaximum(max)
self.ui.progressBar.setValue(progress)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco




More information about the Python-list mailing list