An instance of the python class (or at least the pyqt ↔ qt reference) does not exist at the time the destroyed timeout expires. You can get around this by creating the destroyed handler of a staticmethod in the class. This way the python method will exist when the destroyed signal is issued.
class MyWidget(QWidget): def __init__(self, parent): super(MyWidget, self).__init__(parent) self.destroyed.connect(MyWidget._on_destroyed) @staticmethod def _on_destroyed():
If you need information related to an instance of a class, you can use functools.partial and an __dict__ instance to pass this information to the kill method.
from functools import partial class MyWidget(QWidget): def __init__(self, parent, arg1, arg2): super(MyWidget, self).__init__(parent) self.arg1 = arg1 self.arg2 = arg2 self.destroyed.connect(partial(MyWidget._on_destroyed, self.__dict__)) @staticmethod def _on_destroyed(d): print d['arg1']
source share