检查PyQt4中QPushButton的状态?

2024-04-25 01:00:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我想写一个状态为QPushButtonif条件。如果按钮被启用,我想执行if。所以,我怎样才能检查按钮的状态。

代码:

self.pushButton = QtGui.QPushButton()
self.pushbutton.setEnabled(False)

self.pushbutton.setEnabled(False) ##some where in the another class I have enabled it this line will not be executed all the time,so I want the check state.

if self.pushbutton.checkstate() == Enabled:  ##??? How to write this condition?
    some code I want to execute

Tags: theto代码selffalseif状态some