QProgressBar is a widget to show process. You’ve likely seen it many times during installations.
The widget shows a bar and you can see the percentage completed. You can set its value with
the method setValue(). Where 50 would set it to 50%.
Download Examples:
Download PyQt examples
QProgressBar
Progressbar
Use the code below to create a progressbar:
self.pbar = QProgressBar(self) |
You can set the value with:
self.pbar.setValue(50) |
That’s all that’s needed to create a progressbar.
To update it’s value, you can use a QTimer.
from PyQt5.QtCore import QBasicTimer |
Call a method every second with these lines:
self.timer = QTimer() self.timer.timeout.connect(self.handleTimer) |
Then update the progressbar value:
def handleTimer(self): |
Example
Copy the code below to see a progressbar counting from 50% to 100%.
The progressbar is updated using the method handleTimer() and a QTimer().
import sys |