Qt and progressBar - how to update

OMS omsdiver at gmail.com
Sun May 16 15:38:04 EDT 2010


On 16 Maj, 20:52, Robert Kern <robert.k... at gmail.com> wrote:
> 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

Thanks. You have saved the day. I knew it must be something only
greenhorn could do.

Once again thanks!



More information about the Python-list mailing list