python-3.x - PyQt5 QLabel 文本没有改变?
问题描述
考虑这个最小的代码片段:
from PyQt5.QtWidgets import QApplication,QWidget,QLabel
app=QApplication([])
w=QWidget()
l=QLabel(w)
l.setText("Ready")
w.show()
def load():
l.setText('Loading...')
some_function()
l.setText('Loaded')
load()
此处所需的输出是QLabel
文本应首先更改为“正在加载...”,然后在 some_function() 完成任务后,应更改为“已加载”
但这不是它的工作方式。“正在加载...”文本永远不会出现。在 some_function() 完成后,它直接从“Ready”跳转到“Loaded”。为什么会这样?
解决方案
推荐阅读
- mysql - 合并 Mysql 数据表服务器端
- ruby-on-rails - 未找到 Heroku 应用页面
- ios - 点击视图时如何使键盘出现并开始编辑文本字段
- python - 如果在循环多个页面时页面上不存在元素,则跳过项目-BeautifulSoup 和 Python
- c++ - 向量中的向量在第二维生成重复值
- python - 如何使用 matplotlib 创建自定义 python 图表
- angular - 如何使用动态组件从角度 5 中的指令中引用父组件
- python - 尝试使用 try except 转换为数字
- android - 更新视图的属性在方法`withStartAction`中没有用
- lets-encrypt - 在 Traefik 中使用现有的 LetsEncrypt 证书