[Qgis-developer] New Python console idea: Expanding the Python console to handle DSLs for plugins eg CADTools

Vincent Picavet vincent.ml at oslandia.com
Thu Jun 16 20:45:13 EDT 2011


Hi,
Le jeudi 16 juin 2011 21:24:21, Charlie Sharpsteen a écrit :
> You may want to look at the IPython console---they have a very nice
> syntax for adding new domain-specific commands which they call "magic
> commands":
> 

Currently Ipython is not compatible with any programe importing Qt stuff. It is 
related to the way they manage threads if I remember well. But everything I 
read regarding this issue lead to a deadend.
So you would have to run it outside of QGIS main program, which in turns leads 
to more issues.
If someone has got some hints about this, they are welcome !
Vincent

>    
> http://ipython.org/ipython-doc/dev/interactive/reference.html#magic-comman
> d-system
> 
> For example, say you want to run a Python function as a command:
> 
>     def say_hello(self, arg):
>       print("Hello, world!")
> 
>     # Grab a hook to the currently running IPython instance:
>     import IPython.ipapi
>     ip = IPython.ipapi.get()
> 
>     # Register a new magic function:
>     ip.expose_magic("hello", say_hello)
> 
> 
> Users can they run magic commands directly at the console level using
> a "%command" syntax:
> 
> In [1]: %hello
> Hello, world!
> 
> 
> IPython 0.11 is scheduled to be released at the end of this month and
> has a slightly different api for registering new magic functions:
> 
>     # Grab a hook to the currently running IPython instance
>     ip = get_ipython()
> 
>     # Register a new magic function
>     ip.define_magic("hello", say_hello)
> 
> 
> I have always thought IPython would be a good replacement for the
> current QGIS console as it has a lot of features such as
> tab-completion, inline help and interactive object inspection that
> saves users a lot of running back and forth between manual pages and
> their workspace. The 0.11 version even has a frontend that is built in
> PyQt which would make it easy to integrate into QGIS as a plugin.
> IPython 0.11 also provides a parallel and distributed computing
> framework that could have very interesting applications for GIS
> algorithms. I was even working on such a plugin a couple of months
> ago.
> 
> Unfortunately I had to shelve the project as IPython decided to
> migrate to Version 2 of the SIP API in order to be compatible with
> PySide as well as PyQt and to be compatible with the rest of the
> Enthought tools for scientific computing in Python. QGIS uses Version
> 1 of the SIP API which is incompatible with Version 2. QGIS could
> migrate to Version 2, but all plugins that use QString or QVariant in
> their Python code would need to replace these with plain Python
> strings and objects as the QString and QVariant classes are no longer
> needed or defined with the Version 2 API.
> 
> Migrating QGIS to the latest version of the SIP API might be a good
> idea in the long run as I think it may have better support for Python
> 3.  Some of the issues were discussed when PySide decided which API to
> support:
> 
>     http://www.pyside.org/docs/pseps/psep-0101.html
> 
> 
> -Charlie
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list