I\'m in a situation where I want to assert the identity of a PyQt5 signal. Specifically, I want to check whether the clicked
signal from a given QPushButton>
Try it:
import sys
from PyQt5.QtWidgets import QApplication, QPushButton
app = QApplication([])
def clickButton(w):
# Check what you clicked here. # <-----
return print(w.text())
widget = QPushButton('Button 1')
widget.clicked.connect(lambda : clickButton(widget))
widget2 = QPushButton('Button 2')
widget2.clicked.connect(lambda : clickButton(widget2))
widget.setGeometry(300, 150, 100, 100)
widget.show()
widget2.setGeometry(450, 150, 100, 100)
widget2.show()
sys.exit(app.exec_())