Created
August 13, 2013 12:25
-
-
Save yanmhlv/6220591 to your computer and use it in GitHub Desktop.
Launch PyQt4 with tornado
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.autoreload | |
from PyQt4 import QtGui | |
import sys | |
class Window(QtGui.QWidget): | |
def __init__(self): | |
super(Window, self).__init__() | |
self.timer = tornado.ioloop.PeriodicCallback(self.printable, 300) | |
self.timer.start() | |
def closeEvent(self, event): | |
tornado.ioloop.IOLoop.instance().stop() | |
def printable(self): | |
print 'hello, tornado!' | |
if __name__ == '__main__': | |
import threading | |
tornado.autoreload.start(io_loop=None, check_time=500) | |
threading.Thread(target = lambda: tornado.ioloop.IOLoop.instance().start()).start() | |
qapp = QtGui.QApplication(sys.argv) | |
w = Window() | |
w.show() | |
sys.exit(qapp.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment