Hello all, There are some fantastic examples on the web about qthread, but none of which seem to be working for me. :/
I have a very simple program, in fact I want it to be the most simple qthread example on the web. My mainfile.py: #!/usr/bin/env python3 import sys, time from PyQt4 import QtCore, QtGui import copytextfromlineedit class StartQT(QtGui.QMainWindow): def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = copytextfromlineedit.Ui_MainWindow() self.ui.setupUi(self) QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.get) def get(self): w = Worker() w.start() class Worker(QtCore.QThread): def __init__(self, parent=None): QtCore.QThread.__init__(self) print("hello world") def __del__(self): self.wait() def run(self): print("run") for value in range(1,101): time.sleep(0.5) print(value) app = QtGui.QApplication(sys.argv) myapp = StartQT() myapp.show() sys.exit(app.exec_()) is my main and this is my copytextfromlineedit.py from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: _fromUtf8 = lambda s: s class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(115, 78) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.pushButton = QtGui.QPushButton(self.centralwidget) self.pushButton.setGeometry(QtCore.QRect(0, 10, 113, 27)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.progressBar = QtGui.QProgressBar(self.centralwidget) self.progressBar.setGeometry(QtCore.QRect(0, 50, 113, 23)) self.progressBar.setProperty("value", 24) self.progressBar.setObjectName(_fromUtf8("progressBar")) MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QObject.connect(self.progressBar, QtCore.SIGNAL(_fromUtf8("valueChanged(int)")), self.pushButton.click) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "TAKE IT", None, QtGui.QApplication.UnicodeUTF8)) I want the progress bar to update while the program is running, but I haven't even got that far because the GUI freezes up like so: http://ikt.id.au/blog/wp-content/uploads/2013/04/notresponding.png I can see the thread still running and printing out numbers even after I force close the gui, so it doesn't make sense to me. I know this is quite a noob question, but if anyone is able to keep the gui alive while the thread runs I would be very appreciative. - ikt
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt