I have a very similar problem in Pyqt to that solved [here](https://eli.thegreenplace.net/2011/04/25/passing-extra-arguments-to-pyqt-slot) and [here](https://stackoverflow.com/questions/4646587/pyqt-slots-with-parameter), where one function is called with different parameters through a lambda.

```
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MyForm(QMainWindow):
    def __init__(self, parent=None):
        super(MyForm, self).__init__(parent)
        button1 = QPushButton('Button 1')
        button2 = QPushButton('Button 2')
        button1.clicked.connect(lambda: self.on_button(1))
        button2.clicked.connect(lambda: self.on_button(2))

        layout = QHBoxLayout()
        layout.addWidget(button1)
        layout.addWidget(button2)

        main_frame = QWidget()
        main_frame.setLayout(layout)

        self.setCentralWidget(main_frame)

    def on_button(self, n):
        print('Button {0} clicked'.format(n))

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    form = MyForm()
    form.show()
    app.exec_()

```

My 2 questions are:

How can I make this work with default arguments?
Is there a solution without using a lambda function? (The only reason I want this is because using lambda functions feels wrong and over-complicated and I feel there might be an easier solution.)

My (non-working) idea would look something like:

```
from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MyForm(QMainWindow):
    def __init__(self, parent=None):
        super(MyForm, self).__init__(parent)
        button1 = QPushButton('Button 1')
        button2 = QPushButton('Button 2')
        button1.clicked.connect(self.on_button()) # this should call on_button with n set to default
        #button1.clicked.connect(lambda: self.on_button()) #this works, but uses a lambda
        button2.clicked.connect(lambda: self.on_button(2))

        layout = QHBoxLayout()
        layout.addWidget(button1)
        layout.addWidget(button2)

        main_frame = QWidget()
        main_frame.setLayout(layout)

        self.setCentralWidget(main_frame)

    def on_button(self, n=1): #using default argument
        print('Button {0} clicked'.format(n))

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    form = MyForm()
    form.show()
    app.exec_()

```