from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import time
class SomeApp(QWidget):
def __init__(self):
QWidget. __init__(self)
self.setWindowTitle('Here we go')
self.bsolve = QPushButton(self)
self.bsolve.setGeometry(QRect(50,50, 40,20))
self.bsolve.setText('!')
self.bsolve.clicked.connect(self.myfoo)
self.bsolve.setToolTip('Press X to win')
self.show()
def myfoo(self):
n = 10
progress = QProgressDialog('In use...', 'Stop!', 0, n, self)
progress.setWindowModality(Qt.WindowModal)
progress.forceShow()
for i in range(n):
progress.setValue(i)
if progress.wasCanceled():
break
time.sleep(1)
progress.setValue(n)
if __name__ == '__main__':
import sys
apl = QApplication(sys.argv)
window = SomeApp()
sys.exit(apl.exec_())
ZnJvbSBQeVF0NS5RdEd1aSBpbXBvcnQgKgpmcm9tIFB5UXQ1LlF0V2lkZ2V0cyBpbXBvcnQgKgpmcm9tIFB5UXQ1LlF0Q29yZSBpbXBvcnQgKgppbXBvcnQgdGltZQoKY2xhc3MgU29tZUFwcChRV2lkZ2V0KToKICAgIGRlZiBfX2luaXRfXyhzZWxmKToKICAgICAgICBRV2lkZ2V0LiBfX2luaXRfXyhzZWxmKQogICAgICAgIHNlbGYuc2V0V2luZG93VGl0bGUoJ0hlcmUgd2UgZ28nKQogICAgICAgIHNlbGYuYnNvbHZlID0gUVB1c2hCdXR0b24oc2VsZikKICAgICAgICBzZWxmLmJzb2x2ZS5zZXRHZW9tZXRyeShRUmVjdCg1MCw1MCwgNDAsMjApKQogICAgICAgIHNlbGYuYnNvbHZlLnNldFRleHQoJyEnKQogICAgICAgIHNlbGYuYnNvbHZlLmNsaWNrZWQuY29ubmVjdChzZWxmLm15Zm9vKQogICAgICAgIHNlbGYuYnNvbHZlLnNldFRvb2xUaXAoJ1ByZXNzIFggdG8gd2luJykKICAgICAgICBzZWxmLnNob3coKQoKICAgIGRlZiBteWZvbyhzZWxmKToKCiAgICAgICAgbiA9IDEwCiAgICAgICAgcHJvZ3Jlc3MgPSBR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