Skip to content Skip to sidebar Skip to footer

Progress Bar With Pyqt

I have a program running many threads, one of them controls the interface and another launches some functions every few seconds. I want the timing thread to update a progress bar b

Solution 1:

You have to define a signal for the Crono object like this:

classCrono(QtCore.QThread):
    tick = QtCore.pyqtSignal(int, name="changed") #New style signaldef__init__(self, parent):
        QtCore.QThread.__init__(self,parent)

    defcheckStatus(self):
        for x inrange(1,101):
            self.tick.emit(x)                     
            time.sleep(1)

Then connect it to a slot of the progress bar.

classWTrainning(wMeta.WMeta, QtGui.QWidget):def__init__(self):
        super(WTrainning, self).__init__()
        self.crono = Crono()

    defcreateUI(self):
        #Create GUI stuff here#Connect signal of self.crono to a slot of self.progressBarself.crono.tick.connect(self.progressBar.setValue)

What you were doing is connect the SIGNAL valueChanged of the progressBar to its own SLOT setValue

Post a Comment for "Progress Bar With Pyqt"