import sys
from PyQt4 import QtCore, QtGui
from calculatorform_ui import Ui_CalculatorForm
from ui_countNumbers import Ui_MainWindow
from time import sleep
class WorkerThread
(QtCore.
QThread): def __init__(self, start, end):
self.start = start
self.end = end
def run(self):
for x in range(start, end):
self.emit(QtCore.SIGNAL("updateProgress"), x)
def __init__(self, parent=None):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
@QtCore.pyqtSignature("")
def on_start_clicked(self):
worker = WorkerThread(self.ui.spFrom.value(), self.ui.spTo.value() + 1);
QtCore.
QObject.
connect(worker, QtCore.
SIGNAL("updateProgress"), self.
updateProgress, QtCore.
Qt.
QueuedConnection) worker.start()
def updateProgress(self, val):
self.ui.progres.setValue(val)
if __name__ == "__main__":
count = CountNumbersForm();
count.show()
sys.exit(app.exec_())
import sys
from PyQt4 import QtCore, QtGui
from calculatorform_ui import Ui_CalculatorForm
from ui_countNumbers import Ui_MainWindow
from time import sleep
class WorkerThread(QtCore.QThread):
def __init__(self, start, end):
QtCore.QThread.__init__(self)
self.start = start
self.end = end
def run(self):
for x in range(start, end):
self.emit(QtCore.SIGNAL("updateProgress"), x)
class CountNumbersForm(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QMainWindow.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
@QtCore.pyqtSignature("")
def on_start_clicked(self):
worker = WorkerThread(self.ui.spFrom.value(), self.ui.spTo.value() + 1);
QtCore.QObject.connect(worker, QtCore.SIGNAL("updateProgress"), self.updateProgress, QtCore.Qt.QueuedConnection)
worker.start()
def updateProgress(self, val):
self.ui.progres.setValue(val)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
count = CountNumbersForm();
count.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks