Using lambda function to pass extra argument to slots using PyQt4 python
When programming with PyQt is useful to pass extra arguments to slots callback methods, in order to execute some code when a UI control's action is invoked.
In this example you can see the usage of lambda expression to pass the extra argument to the method invoked when pressing a button.
Thanks to http://eli.thegreenplace.net/2011/04/25/passing-extra-arguments-to-pyqt-slot/
post this code
self.greeting = QLabel('', self)
# Create the build button with its caption
self.build_button = QPushButton('&Build Greeting', self)
# Connect the button's clicked signal to AddControl
def AddControl(self, name):
self.greeting.setText('%s!' % (name))
If you want to be updated about similar snippets,
and follow our Channels