私は PyQt GUI を使用して、imaplib を使用して新しいメールがあるかどうかを確認する python プログラムを作成しました。コードの一部は次のとおりです。
def getAccountStatus(self, accountIndex):
# some not interesting code
mail = imaplib.IMAP4_SSL(currentHost)
# some not interesting code
mail.login('user', 'pass')
mailCount = int(mail.select("INBOX", True)[1][0])
# some not interesting code
serverResponse, data = mail.uid('search', None, 'UNSEEN')
# some not interesting code
unseenUidList = data[0].split()
# some not interesting code
self.emailAccountsWidget.setText("<BR>".join(self.accountStatusString))
return [mailCount, len(unseenUidList)]
問題は、imap サーバーからデータを取得するこのプロセス中に GUI がフリーズし、ウィンドウの再描画イベントを明示的に呼び出さないと TextEdit (self.emailAccountsWidget) でさえテキストを更新しないことです。これを回避するための回避策はありますか?