Skip to content

Instantly share code, notes, and snippets.

@estan
Last active November 4, 2015 15:43
Show Gist options
  • Save estan/5a85040c594b92d0bae2 to your computer and use it in GitHub Desktop.
Save estan/5a85040c594b92d0bae2 to your computer and use it in GitHub Desktop.
Application won't quit on last window closed with qtreactor
diff --git a/qtreactor/qt4base.py b/qtreactor/qt4base.py
index 076599e..88af08c 100644
--- a/qtreactor/qt4base.py
+++ b/qtreactor/qt4base.py
@@ -273,7 +273,8 @@ class QtReactor(posixbase.PosixReactorBase):
else:
self._blockApp = QtCore.QEventLoop()
self.runReturn()
- self._blockApp.exec_()
+ #self._blockApp.exec_()
+ self.qApp.exec_()
class QtEventReactor(QtReactor):
from __future__ import print_function
from sys import argv
from PyQt4.QtGui import QMessageBox, QApplication
import qt4reactor
if __name__ == '__main__':
app = QApplication(argv)
app.lastWindowClosed.connect(lambda: print('Last window closed'))
qt4reactor.install()
box = QMessageBox(QMessageBox.Information, 'Test', 'Running with Qt reactor')
box.show()
from twisted.internet import reactor
reactor.run()
from __future__ import print_function
from sys import argv, exit
from PyQt4.QtGui import QMessageBox, QApplication
if __name__ == '__main__':
app = QApplication(argv)
app.lastWindowClosed.connect(lambda: print('Last window closed'))
box = QMessageBox(QMessageBox.Information, 'Test', 'Running without Qt reactor')
box.show()
exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment