Answer the question
In order to leave comments, you need to log in
Multithreading in Python (PyQt5)?
When the button is clicked, the "long-term" run() function is launched, in which I need to edit widgets or take values from them (for example, take text from Qlineedit). I don't understand how it can be done
class Worker(QObject):
finished = pyqtSignal()
def run(self, AuctionID_raw, Price, data3, AuctionID, place):
while True:
login = self.lineEdit.text()
.
.
.
class mywindow(QtWidgets.QMainWindow):
def btnCkicked_2(self):
.
.
.
self.thread = QThread()
self.worker = Worker()
self.worker.moveToThread(self.thread)
self.thread.started.connect(self.worker.run(AuctionID_raw, Price, data3, AuctionID, place))
self.worker.finished.connect(self.thread.quit)
self.worker.finished.connect(self.worker.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
self.thread.start()
Answer the question
In order to leave comments, you need to log in
All interaction of flows and graphics - to take out in signals.
You must pass to it all the data it needs to work with- load all the necessary data before starting, if the data has changed and the worker needs to receive it, send it to the worker using a signal. When a worker has done a part, it sends the result in a signal.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question