python中多个QPushButton响应同一个事件
注:在python2 的环境下运行
#! -*- coding:utf-8 -*-
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton
import sys
class WindowDemo(QWidget):
def __init__(self):
super(WindowDemo, self).__init__()
btn1 = QPushButton(u'单一保存', self)
btn2 = QPushButton(u'连续保存', self)
btn3 = QPushButton(u'暂停连续保存', self)
btn1.clicked.connect(self.handle_camsave)
btn2.clicked.connect(self.handle_camsave)
btn3.clicked.connect(self.handle_camsave)
hbox = QHBoxLayout()
hbox.addWidget(btn1)
hbox.addWidget(btn2)
hbox.addWidget(btn3)
hbox.addStretch(0)
self.setLayout(hbox)
self.setWindowTitle("addStretch 例子")
def handle_camsave(self):
sender = self.sender()
clickevent = sender.text()
if clickevent =