[IPython-dev] QtConsole signal handling

Tiago Coutinho coutinhotiago at gmail.com
Fri Jul 13 05:45:22 EDT 2012


Hello,

I have written an ipython extension for a library called PyTango.

In this extension I subscribe to events through a callback function which
is executed in a "random" thread.
The callback simply uses pylab to do a plot using the event information.

1. In IPython 0.10:
  To avoid Qt calls outside the MainThread the callback actually emits a
signal. The slot which is connected to it does the actual pylab.plot call.
  I simply activate -pylab and -q4thread and everything works fine.

2. In IPython 0.12 / 0.13:
  2.1 If ipython is started in console mode the solution I used for IPython
0.10 works like a charm
  2.2 If ipython is started in qtconsole mode with pylab=qt the solution I
used for IPython 0.10 also works

  2.3 If ipython is started in qtconsole mode with pylab='inline' the
solution I used for IPython 0.10 doesn't work (the signal is emited but the
slot is never called).
    2.3.1 If I replace the callback that emits a signal with the actual
plot then it works... but then cases 2.1 and 2.2  don't work anymore.

I guess the solution here is to determine in which of the following 3
"modes" the ipython is running
  - terminal-based with pylab=qt
  - QtConsole with pylab=qt
  - QtConsole with pylab=inline

I know how to check for pylab mode:
app = IPython.Application.instance()
app.pylab == "qt"

... but how do I find out which is the fronted being used?
I wanted to avoid something nasty like for obvious reasons:
app = IPython.Application.instance()
is_terminal_based =
isinstance(app, IPython.frontend.terminal.ipapp.TerminalIPythonApp)

is_qt_console = isinstance(app, IPython.zmq.ipkernel.IPKernelApp)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20120713/ff159678/attachment.html>


More information about the IPython-dev mailing list