[Qgis-developer] Re: PyQGIS Auto-completion and Call Tips in Eric Python Editor

Larry Shaffer larrys at dakotacarto.com
Tue Apr 10 01:10:14 EDT 2012


On Mon, Apr 9, 2012 at 4:37 PM, Larry Shaffer <larrys at dakotacarto.com>wrote:

> Hi Tim,
>
> On Mon, Apr 9, 2012 at 1:00 PM, Tim Sutton <lists at linfiniti.com> wrote:
>
>> ...
>>
> 2) What I would really *love* is to have QGIS api completion (and
>> other standard python modules if it is easy to achieve) in the built
>> in python console that is activeated from the QGIS plugins menu. I
>> often like to demo stuff to people using the python console and always
>> flap around trying to remember syntax. Obviously this would add a
>> qsctintilla dependency to QGIS core - how do others feel about this?
>> Given the other work you are busy with that dependency is probably
>> coming anyway....
>>
>
>  :^)  Porting the QTextEdit of PyQGIS console.py to QScintilla was what I
> was going to look into next. I have already bootlegged it into Plugin
> Editor and done some customizations.
>
> The Eric editor has a nice Python console based on QScintilla (syntax
> coloring, code completion and call tips), but I had difficulty trying to
> port it to Plugin Editor, because it leverages Eric's entrenched debugger
> classes. The ported base debugger I tried consistently crashed QGIS. Maybe
> it can be included in a later version.
>
> Currently I have code completion and call tips working well in Plugin
> Editor [0]. The compiled API files I am testing with are:
>
>     PyQt4-Qt4.8.api, Python-2.7.api, QScintilla2.api
>     qgis.analysis.api, qgis.console.api, qgis.core.api, qgis.gui.api,
> qgis.utils.api
>
> The compiled API 'python.pap' file for a given QScintilla editor widget is
> ~37,500 api items total, and 900 KB in size (yet is still quite responsive).
>


Having played around with the code completion, I added another .api file
for the qgis.utils.iface instance [0]. This allows direct access to the 149
QgisInterface slots/functions when typing just 'iface' [1], which is common.

@Tim - I have recently added templates (built-in and custom) to Plugin
Editor as well. Using the run_script() template (formulated as per Script
Runner) you can quickly open a test script, with code completion and call
tips, type a few lines and run it within the Editor. Also, you can copy
text selections via drag/drop to the PyQGIS console for running. Those
steps would help you to show some example code quickly.

Switching from QTextEdit to QScintilla for the console looks like about a
50% rewrite, plus some refactoring. Certainly an all-weekend kinda project,
considering new features would be added, too.

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota

[0] http://dl.dropbox.com/u/4058089/qgis/qgis.utils.iface.api
[1] http://dl.dropbox.com/u/4058089/qgis/qgis-qsci-iface.png
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120409/8997f0ec/attachment.html


More information about the Qgis-developer mailing list