def timerEvent(self, event): QObject.timerEvent(self, event) event.accept() self.times_called += 1 if self.times_called == 5: self.app.exit(0)