首页 > 解决方案 > 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()

标签: pythonpython-2.7pyqt5

解决方案


推荐阅读