Issue
I have what I think is a repainting issue with a PySide widget. How can I force the widget (or the whole window/app) to repaint in the middle of a method?
def on_button_clicked():
window.resultTextEdit.setPlainText("Parsing file...")
# indicate delay, this message should be visible while parsing
# but in fact it never appears
# can I force a repaint here?
result = parse() # (takes a little while)
window.resultTextEdit.setPlainText(result)
# display the results once done
app = QApplication(sys.argv)
window = QtUiTools.QUiLoader().load("application.ui")
window.userButton.clicked.connect(on_button_clicked)
window.show()
sys.exit(app.exec_())
Solution
For any widget that needs a repaint in the middle of an event, you can simply call widget.repaint()
. Note that the rest of UI is unresponsive during the repaint (which is fine for a one-off call, but not if you're repainting repeatedly).
(Thanks Mel for pointing me to https://stackoverflow.com/a/11806126/4720935 )
Answered By - lofidevops
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.