Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import sys
  2. import time
  3.  
  4. from PyQt5.QtWidgets import (QApplication, QDialog,
  5. QProgressBar, QPushButton)
  6.  
  7. TIME_LIMIT = 100
  8.  
  9. class Actions(QDialog):
  10. """
  11. Simple dialog that consists of a Progress Bar and a Button.
  12. Clicking on the button results in the start of a timer and
  13. updates the progress bar.
  14. """
  15. def __init__(self):
  16. super().__init__()
  17. self.initUI()
  18.  
  19. def initUI(self):
  20. self.setWindowTitle('Progress Bar')
  21. self.progress = QProgressBar(self)
  22. self.progress.setGeometry(0, 0, 300, 25)
  23. self.progress.setMaximum(100)
  24. self.button = QPushButton('Start', self)
  25. self.button.move(0, 30)
  26. self.show()
  27.  
  28. self.button.clicked.connect(self.onButtonClick)
  29.  
  30. def onButtonClick(self):
  31. count = 0
  32. while count < TIME_LIMIT:
  33. count += 1
  34. time.sleep(1)
  35. self.progress.setValue(count)
  36.  
  37. if __name__ == "__main__":
  38. app = QApplication(sys.argv)
  39. window = Actions()
  40. sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement