Created
June 15, 2019 14:23
-
-
Save vivekjoshy/6c7214cd15a927c893d8ae7072c8fb8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
from PyQt5.QtWidgets import (QApplication, QDialog, | |
QProgressBar, QPushButton) | |
TIME_LIMIT = 100 | |
class Actions(QDialog): | |
""" | |
Simple dialog that consists of a Progress Bar and a Button. | |
Clicking on the button results in the start of a timer and | |
updates the progress bar. | |
""" | |
def __init__(self): | |
super().__init__() | |
self.initUI() | |
def initUI(self): | |
self.setWindowTitle('Progress Bar') | |
self.progress = QProgressBar(self) | |
self.progress.setGeometry(0, 0, 300, 25) | |
self.progress.setMaximum(100) | |
self.button = QPushButton('Start', self) | |
self.button.move(0, 30) | |
self.show() | |
self.button.clicked.connect(self.onButtonClick) | |
def onButtonClick(self): | |
count = 0 | |
while count < TIME_LIMIT: | |
count += 1 | |
time.sleep(1) | |
self.progress.setValue(count) | |
if __name__ == "__main__": | |
app = QApplication(sys.argv) | |
window = Actions() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment