[IPython-dev] Comments on IPython Qt widgets

Charlie Sharpsteen source at sharpsteen.net
Mon Feb 7 21:52:23 EST 2011


Hello IPython developers,

I was playing around with the new Qt  widgets in 0.11-dev the other day and
was very impressed.  I tried throwing together a quick plugin to add an
IPython console to the Qt-based program Quantum GIS [QGIS][1].  Creating the
plugin was easy enough as QGIS runs an embedded Python interpreter and
exposes a lot of PyQt4 functionality.  However, I noticed a couple of things
and was wondering if anyone on this list had any comments to share:


- The shell is based on a stripped down version of `ipython-qtconsole` and
works but is very, very slow for some reason.  The is a delay of a couple of
seconds between when an action is triggered and a response comes back to the
terminal.  The only guess I have that may explain this behavior is that QGIS
is a C++ application that embeds a Python interpreter whereas
ipython-qtconsole is a pure PyQt4 program.  Perhaps QGIS is not letting the
Python threads run as often as a pure PyQt4 program would.

This could be a QGIS-specific problem, but I was wondering if anyone else
had the chance to run the IPython Qt widget in an embedded interpreter and
noticed similar results?


- Currently, the only IPython kernel available for use with the Qt widget
runs the IPython interpreter in a separate process.  For QGIS, it would be
very nice to have the option of running an IPython kernel inside the same
process as the Qt widgets.  IPython would then have direct access to the
QGIS interface and would be able to inspect and operatie on the PyQt4
objects that compose the GUI providing a powerful tool for users performing
spatial analysis and developers building plugins.

Are there any plans to develop IPython kernels that do not run
in separate processes?  I spent a few days trying to build one myself by
wrapping an InteractiveShell, but I feel like I am flailing a little bit
when it comes to creating a kernel_manager that will integrate with the Qt
frontend.  If anyone has any design advice on how to implement an in-process
kernel I would love to hear it.


The plugin is available on [GitHub][2] under the tag `0.1` if anyone feels
interested in checking it out as an IPython use case.  The 0.1 version is
really quite simple---about 5-10 lines in console.py that do the actual
implementation.  To use:

  - Install QGIS
  - Clone project as a sub-directory of ~/.qgis/python/plugins/
  - Run `make` (runs PyQt4 dev tools on ui and qrc files)
  - Launch QGIS and enable Plugin through Plugins -> Manage Plugins menu


Keep up the good work on IPython development!

-Charlie

[1]: http://www.qgis.org
[2]: http://www.github.com/Sharpie/qgis-ipython/tree/0.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20110207/0cb5f259/attachment.html>


More information about the IPython-dev mailing list