I am trying to make a mailbox checker with imap lib, it work pretty fine with python, queue and multithread without gui.
But when I try to put a gui, ev
I can't test because setimap is not available on my system. I renamed CheckerThread to Checker since it is no longer a thread (it just "lives" in a thread):
class Checker(QtCore.QObject):
Then just replace the contents of the loop in gogogo(self) with this:
for lignesmailtocheck in sorted(setmailtocheck):
checker = Checker(lignesmailtocheck)
thread = QThread()
checker.moveToThread(thread)
# connections after move so cross-thread:
thread.started.connect(checker.run)
checker.signal.connect(self.checkedok)
thread.start()
self.threads.append(thread)
It is almost always a good idea to decorate slots with pyqtSlot so both run and checkedok should be thus decorated.
The SO answer about Qt threads is quite handy to remind yourself of details (note however that it uses old-style connections -- you have to translate C++ connect( sender, SIGNAL(sig), receiver, SLOT(slot)); to PyQt5 sender.sig.connect(receiver.slot)).