<p>您可以使用QpushButton和样式表。这是密码</p>
<pre><code>if(process==running):
button.setStyleSheet(ENABLE_STYLESHEET )
else
button.setStyleSheet(DISABLE_STYLESHEET )
</code></pre>
<p>您可以定义如下样式表</p>
<pre><code>ENABLE_STYLESHEET = """
QPushButton {
border: 1px solid #007a94;
border-radius: 6px;
color:#ffffff;
background-color: #007a94;
min-width: 80px;
}
QPushButton:pressed {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #008aa6, stop: 1 #008aa6);
}
QPushButton:flat {
border: none;
}
"""
DISABLE_STYLESHEET = """
QPushButton {
border: 1px solid #808080;
border-radius: 6px;
color:#ffffff;
background-color: #808080;
min-width: 80px;
}
QPushButton:flat {
border: none;
}
"""
</code></pre>
<p><a href="https://i.stack.imgur.com/2NRnA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2NRnA.png" alt="Enable Button"/></a>
<a href="https://i.stack.imgur.com/pMCoX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pMCoX.png" alt="Disable Button"/></a></p>