Skip to content

Instantly share code, notes, and snippets.

@yanmhlv
Created August 13, 2013 12:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanmhlv/6220591 to your computer and use it in GitHub Desktop.
Save yanmhlv/6220591 to your computer and use it in GitHub Desktop.
Launch PyQt4 with tornado
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