# Time: 2021/06/30
#Author: Xiaohong
# 运行环境: OS: Windows 7
# Python: 3.7
# 功能: QPushButton 点击事件(三个按钮共用一个处理方法)
界面效果如下:
源代码如下:
from PyQt5.QtWidgets import QWidget,QPushButton,QFrame,QApplication
from PyQt5.QtGui import QColor
import sys
class PushButton(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.color = QColor(0,0,0)
redButton = QPushButton('红',self)
redButton.setCheckable(True)
redButton.move(10,10)
redButton.clicked[bool].connect(self.setColor)
greenButton = QPushButton('绿',self)
greenButton.setCheckable(True)
greenButton.move(10,60)
greenButton.clicked[bool].connect(