Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # Form implementation generated from reading ui file 'pro2.ui'
  4. #
  5. # Created by: PyQt4 UI code generator 4.11.4
  6. #
  7. # WARNING! All changes made in this file will be lost!
  8.  
  9. from PyQt4 import QtCore, QtGui
  10. import sys
  11.  
  12. try:
  13. _fromUtf8 = QtCore.QString.fromUtf8
  14. except AttributeError:
  15. def _fromUtf8(s):
  16. return s
  17.  
  18. try:
  19. _encoding = QtGui.QApplication.UnicodeUTF8
  20. def _translate(context, text, disambig):
  21. return QtGui.QApplication.translate(context, text, disambig, _encoding)
  22. except AttributeError:
  23. def _translate(context, text, disambig):
  24. return QtGui.QApplication.translate(context, text, disambig)
  25.  
  26. class Ui_Form(QtGui.QWidget):
  27. def __init__(self):
  28. QtGui.QWidget.__init__(self)
  29. self.setupUi(self)
  30.  
  31. def setupUi(self, Form):
  32. Form.setObjectName(_fromUtf8("Form"))
  33. Form.resize(400, 300)
  34. self.progressBar = QtGui.QProgressBar(Form)
  35. self.progressBar.setGeometry(QtCore.QRect(160, 60, 118, 23))
  36. self.progressBar.setProperty("value", 24)
  37. self.progressBar.setObjectName(_fromUtf8("progressBar"))
  38. self.pushButton = QtGui.QPushButton(Form)
  39. self.pushButton.setGeometry(QtCore.QRect(170, 140, 75, 23))
  40. self.pushButton.setObjectName(_fromUtf8("pushButton"))
  41. # # restarts the 'QProgressBar'
  42. self.progressBar.reset()
  43.  
  44. # creates a 'QTimer'
  45. self.qtimer = QtCore.QTimer()
  46.  
  47. # connects the 'QTimer.timeout()' signal with the 'qtimer_timeout()' slot
  48. self.qtimer.timeout.connect(self.qtimer_timeout)
  49.  
  50. self.retranslateUi(Form)
  51. QtCore.QMetaObject.connectSlotsByName(Form)
  52.  
  53. def retranslateUi(self, Form):
  54. Form.setWindowTitle(_translate("Form", "Form", None))
  55. self.pushButton.setText(_translate("Form", "start", None))
  56. self.pushButton.clicked.connect(self.qpushbutton_clicked)
  57.  
  58. def qpushbutton_clicked(self):
  59.  
  60. self.progressBar.reset()
  61.  
  62. #this is the method that needs the time to complete the progress bar
  63. self.methodtobeexecute()
  64.  
  65. self.qtimer.start(40)
  66.  
  67. def qprogressbar_value_changed(self, value):
  68. if value == self.progressBar.maximum():
  69. # stops the 'QTimer'
  70. self.qtimer.stop()
  71.  
  72. def qtimer_timeout(self):
  73. # gets the current value of the 'QProgressBar'
  74. value = self.progressBar.value()
  75.  
  76. # adds 1 to the current value of the 'QProgressBar'
  77. self.progressBar.setValue(value + 1)
  78.  
  79. def methodtobeexecute(self):
  80. for i in 400:
  81. print(i)
  82.  
  83.  
  84.  
  85.  
  86.  
  87. def main():
  88. app = QtGui.QApplication(sys.argv)
  89. mw = Ui_Form()
  90. mw.show()
  91. sys.exit(app.exec_())
  92.  
  93. if __name__ == "__main__":
  94. main()
Add Comment
Please, Sign In to add comment