python - PyQt5 函数 setVisible 在 Python 中不起作用
问题描述
我试图在 PyQt5 和 Python 中的特定时间后更改按钮的可见性,但它不起作用。它在控制台中显示此错误
self.done_btn.setVisible(True) AttributeError: 'MainWindow' 对象没有属性 'done_btn'
在计时器 按钮之前应该被隐藏
done_btn = QAction(QIcon(os.path.join('images', 'done.png')), "Done", self)
done_btn.setVisible(False)
done_btn.triggered.connect(self.start_earning)
guide.addAction(done_btn)
计时器 之后计时器完成按钮应该可见
def timeout(self):
self.guidestate.setText('hello world')
self.done_btn.setVisible(True)
定时器
t = Timer(5, self.timeout)
t.start()
解决方案
推荐阅读
- python-3.x - 使用 with 访问 python 上下文,而不将其作为变量传递?
- javascript - 如何让一个 Vue 组件占据整个浏览器高度?
- node.js - Google Pub/Sub pull 方法每 1 分钟重启一次 express 服务器
- java - 无法从 Java Android Studio 中的另一个类调用变量
- treeview - 树视图中的 Odoo 装饰不起作用?
- r - R Keras Particule Swarm:参数不是数字或逻辑的
- google-picker - 打开选择了已知 fileId 的驱动器选择器
- node.js - 将谷歌聊天与电子邮件对话流集成
- jmeter - 如何为特定线程组执行拆卸
- c++ - 基类指针向量的正确内存释放,它是派生类的成员