I have a signal, which just needs to do one thing: if emitted assign a variable a given value. It seems stupid to create a method for this, so I was thinking: Is there a way to do something like this:
self.myButton.clicked.connect(self.someVariable = None)
Use lambda:
Notes:
selfis referenced upon slot call, so you might want to do:self.myButton.clicked.connect(lambda self=self: self.someVariable = None)Some widget send signals with parameters, and you have to put them in lambda definition.
self.myButton.clicked.connect(lambda checked=False, self=self: self.someVariable = None)UPDATE:
Assignments are not allowed in lambda, so you will have to use real function or something like this: