[IPython-dev] Twisted reactor + IPython0
Glenn H Tarbox, PhD
Wed Mar 19 17:51:34 CDT 2008
from PyQt4 import QtGui
this nails up the reactor and makes app available
at the module level
app = QtGui.QApplication(sys.argv)
# alternative for those who don't need a gui
# from twisted.application import reactors
from twisted.internet import reactor
# now you have the thread back, a live Qt application object, and
# twisted... and you've got the IPython0 prompt back... then try
print "he called me"
you'll have the prompt back and 5 seconds later it'll print
On Wed, 2008-03-19 at 15:35 -0700, Glenn H Tarbox, PhD wrote:
> This is where I started originally. There's a better fix which I posted
> a while ago. The below uses polling which is unnecessary. By modifying
> shell, you can turn the whole thing into a callback.
> A better approach is to use my qtreactor (it sucks in qt but) because
> you can instantiate twisted (and qt) and keep the event loop for
> stdin/stdout and have reactor behavior as well.
> the key with qtreactor is I made a new call = reactor.runReturn() which
> nails up the reactor to the Qt application, sets up the timers etc, but
> returns the thread to you... so as long as I/O in IPython doesn't block
> (which it only does when scrolling more than a page)
> On Wed, 2008-03-19 at 23:39 +0200, Ville M. Vainio wrote:
> > This is related to the recent thread about reactors, GUI support etc.
> > Would it make sense to provide direct twisted reactor support for ipython0?
> > There is a recipe for this:
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/410670
> > If this works as expected, can't we just implement all the GUI support
> > widgets in terms of this baby, using the support bundled with twisted?
> > A couple of you have gathered extensive experience with Twisted, what
> > do you think?
Glenn H. Tarbox, PhD
More information about the IPython-dev