fork(1) download
  1. from PyQt5.QtGui import *
  2. from PyQt5.QtWidgets import *
  3. from PyQt5.QtCore import *
  4. import time
  5.  
  6. class SomeApp(QWidget):
  7. def __init__(self):
  8. QWidget. __init__(self)
  9. self.setWindowTitle('Here we go')
  10. self.bsolve = QPushButton(self)
  11. self.bsolve.setGeometry(QRect(50,50, 40,20))
  12. self.bsolve.setText('!')
  13. self.bsolve.clicked.connect(self.myfoo)
  14. self.bsolve.setToolTip('Press X to win')
  15. self.show()
  16.  
  17. def myfoo(self):
  18.  
  19. n = 10
  20. progress = QProgressDialog('In use...', 'Stop!', 0, n, self)
  21. progress.setWindowModality(Qt.WindowModal)
  22. progress.forceShow()
  23. for i in range(n):
  24.  
  25. progress.setValue(i)
  26. if progress.wasCanceled():
  27. break
  28.  
  29. time.sleep(1)
  30.  
  31. progress.setValue(n)
  32.  
  33. if __name__ == '__main__':
  34. import sys
  35. apl = QApplication(sys.argv)
  36. window = SomeApp()
  37. sys.exit(apl.exec_())
  38.  
Runtime error #stdin #stdout #stderr 0.02s 8736KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'PyQt5'