機能が開き、正規表現は、いくつかのテキストに置き換えます。Pythonの3.1PyQtは "フラッシュ" と同等
def process(self):
# first do this!!
self.label.setText('Processing for 5-10 sec.....')
self.button.setEnabled(0)
# and only then heavy files operations
file = open(self.filename, mode='r', encoding='utf-8')
text = re.sub(r'^ (.+)\n ', r' \[\1\]\n ', file.read(), flags=re.MULTILINE)
newfile = open(self.filename+'temp', mode='w', encoding='utf-8')
file_new.write(text)
self.label.setText('Ready')
を、PyQtは4.8.2
ファイルは十分な大きさで、操作は〜10秒かかります。
ボタンを押したときに、拳がラベル内のテキストを置き換えてボタンを無効にします。ユーザーは、しばらく待たなければならないことがわかります。
しかし、何も起こりません。システムは10秒間停止し、「準備完了」ラベルが表示され、ボタンが無効になります。
どうすればQtをラベル変更してボタンを無効にすることができますか?
processEvents()が動作し、spasibo! – Qiao