Just additional information, I donβt know why, but the lambda function does not work with the new pyqt syntax for connections:
Sample code does not work:
self.contextTreeMenuAssignTo = QtGui.QMenu(self) actionAssign = contextMenu.addMenu( self.contextTreeMenuAssignTo ) actionAssign.setText("Assign to : ") for user in self.whoCanBeAssignated() : actionAssignTo = QtGui.QAction( user[0] ,self) self.contextTreeMenuAssignTo.addAction( actionAssignTo ) actionAssignTo.triggered.connect( lambda userID = user[1] : self.assignAllTo( userID ) )
But if you sign the last line with the old-style syntax:
self.connect(actionAssignTo, QtCore.SIGNAL('triggered()'), lambda userID = user[1] : self.assignAllTo( userID ) )
Everything is good. With the new join syntax, you only get the last element of the loop :(
glyphosate
source share