In this snippet of code I am attempting to pass a parameter to buttonClicked() and it is failing with parameter of type NoneType. Is there a reason why my function is not accepting the "1" string parameter?
import sys
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
class Example(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
btn1 = QPushButton("Button 1", self)
btn1.move(30, 50)
# This code ties the slots and signals together
# clicked is the SIGNAL
btn1.clicked.connect(self.buttonClicked("1"))
self.statusBar()
self.setGeometry(300, 300, 300, 230)
self.setWindowTitle('Event sender')
self.show()
def buttonClicked(self, buttonNumber):
sender = self.sender()
self.statusBar().showMessage(buttonNumber + ' was pressed')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())