您可以使用 QpushButton 和样式表。这是代码
if(process==running):
button.setStyleSheet(ENABLE_STYLESHEET )
else
button.setStyleSheet(DISABLE_STYLESHEET )
你可以定义样式表如下
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;
}
"""