Details
Description
Example:
from PySide.QtCore import * from PySide.QtGui import * class Connector(object): def __init__(self): button.clicked.connect(self.slot) def slot(self): print 'Clicked' app = QApplication(()) button = QPushButton('Press me') Connector() button.show() app.exec_()
Wrapping self.slot in a function surprisingly causes this example to work, albeit in an ugly way:
from PySide.QtCore import * from PySide.QtGui import * class Connector(object): def __init__(self): # `self.slot` -> `lambda: self.slot()` button.clicked.connect(lambda: self.slot()) def slot(self): print 'Clicked' app = QApplication(()) button = QPushButton('Press me') Connector() button.show() app.exec_()
This problem can be avoided altogether by assigning the connector instance to a variable (e.g. connector = Connector(), but it shouldn't be necessary to do this.