Discussion:
[Qgis-developer] PyQGIS Auto-completion and Call Tips in Eric Python Editor
Larry Shaffer
2012-04-09 02:49:08 UTC
Permalink
Hi,

I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor (or
another based on QScintilla2), you may be interested in installing and
compiling these APIs.

This allows for auto code completion and/or call tips for 3,450 items in
the QGIS API:

qgis.core.api
qgis.gui.api
qgis.analysis.api
qgis.utils.api
qgis.console.api

Also included in the archive is a description of how to reproduce the API
files and some screen snaps on using with Eric4. The CMake edit might be
considered for inclusion in the QGIS source, but (I suggest) only with an
additional compile option for triggering creation of the API files, since
it is not usually necessary to produce them, excepting for when the API
changes.

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota

[0] http://dl.dropbox.com/u/4058089/qgis/qgis-qsci-apis.zip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120408/9bb6555f/attachment.html
Larry Shaffer
2012-04-09 04:21:34 UTC
Permalink
Post by Larry Shaffer
Hi,
I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor (or
another based on QScintilla2), you may be interested in installing and
compiling these APIs.
Seems a better approach, instead of changing SIPMacros.cmake, would be in
python/CMakeLists.txt [0]:

--- python/CMakeLists_orig.txt 2012-02-19 13:41:41.000000000 -0700
+++ python/CMakeLists.txt 2012-04-08 21:00:16.000000000 -0600
@@ -54,0 +55 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.core.api)
@@ -68,0 +70 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.gui.api)
@@ -79,0 +82 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.analysis.api)

This worked fine on compile, creating the same output as the
SIPMacros.cmake edit. Each SIP_EXTRA_OPTIONS could be wrapped with a
conditional based on a compile option for generating the APIs.

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota

[0] http://dl.dropbox.com/u/4058089/qgis/CMakeLists.txt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120408/cc594f3c/attachment.html
Tim Sutton
2012-04-09 20:00:56 UTC
Permalink
Hi Larry
Post by Larry Shaffer
Post by Larry Shaffer
Hi,
I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor (or
another based on QScintilla2), you may be interested in installing and
compiling these APIs.
Seems a better approach, instead of changing SIPMacros.cmake, would be in
--- python/CMakeLists_orig.txt??? 2012-02-19 13:41:41.000000000 -0700
+++ python/CMakeLists.txt??? 2012-04-08 21:00:16.000000000 -0600
@@ -54,0 +55 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.core.api)
@@ -68,0 +70 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.gui.api)
@@ -79,0 +82 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.analysis.api)
This worked fine on compile, creating the same output as the SIPMacros.cmake
edit. Each SIP_EXTRA_OPTIONS could be wrapped with a conditional based on a
compile option for generating the APIs.
Two quick comments:

1) Could you submit your patch via github? If it is a cmake
conditional compilation I see no reason to exclude it from master -
others may have a different opinion.
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....


Regards

Tim
Post by Larry Shaffer
Regards,
Larry Shaffer
Dakota Cartography
Black Hills, South Dakota
[0] http://dl.dropbox.com/u/4058089/qgis/CMakeLists.txt
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Tim Sutton - QGIS Project Steering Committee Member (Release? Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
?* QGIS programming and support services
?* Mapserver and PostGIS based hosting plans
?* FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================
G. Allegri
2012-04-09 21:06:07 UTC
Permalink
I would seriously consider upgrading the Python console, first of all to
support autocompletion. I suggested the incorporation of QScintilla a
couple of years ago, but it didn't raise much interest. A few weeks ago I
gave a look to iPython, and it's Qt console [1].

giovanni

[1] http://ipython.org/ipython-doc/dev/interactive/qtconsole.html
Post by Tim Sutton
Hi Larry
Post by Larry Shaffer
Post by Larry Shaffer
Hi,
I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor
(or
Post by Larry Shaffer
Post by Larry Shaffer
another based on QScintilla2), you may be interested in installing and
compiling these APIs.
Seems a better approach, instead of changing SIPMacros.cmake, would be in
--- python/CMakeLists_orig.txt 2012-02-19 13:41:41.000000000 -0700
+++ python/CMakeLists.txt 2012-04-08 21:00:16.000000000 -0600
@@ -54,0 +55 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.core.api)
@@ -68,0 +70 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.gui.api)
@@ -79,0 +82 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.analysis.api)
This worked fine on compile, creating the same output as the
SIPMacros.cmake
Post by Larry Shaffer
edit. Each SIP_EXTRA_OPTIONS could be wrapped with a conditional based
on a
Post by Larry Shaffer
compile option for generating the APIs.
1) Could you submit your patch via github? If it is a cmake
conditional compilation I see no reason to exclude it from master -
others may have a different opinion.
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....
Regards
Tim
Post by Larry Shaffer
Regards,
Larry Shaffer
Dakota Cartography
Black Hills, South Dakota
[0] http://dl.dropbox.com/u/4058089/qgis/CMakeLists.txt
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Tim Sutton - QGIS Project Steering Committee Member (Release Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.
* QGIS programming and support services
* Mapserver and PostGIS based hosting plans
* FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120409/f0472f69/attachment.html
Etienne Tourigny
2012-04-09 22:38:37 UTC
Permalink
It certainly looks good - but how about installing it along with it's
dependencies (such ZeroMQ and PyZMQ), particularly in windows or mac?

Etienne
Post by G. Allegri
I would seriously consider upgrading the Python console, first of all to
support autocompletion. I suggested the incorporation of QScintilla a couple
of years ago, but it didn't raise much interest. A few weeks ago I gave a
look to iPython, and it's Qt console [1].
giovanni
[1]? http://ipython.org/ipython-doc/dev/interactive/qtconsole.html
Post by Tim Sutton
Hi Larry
Post by Larry Shaffer
Post by Larry Shaffer
Hi,
I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor (or
another based on QScintilla2), you may be interested in installing and
compiling these APIs.
Seems a better approach, instead of changing SIPMacros.cmake, would be in
--- python/CMakeLists_orig.txt??? 2012-02-19 13:41:41.000000000 -0700
+++ python/CMakeLists.txt??? 2012-04-08 21:00:16.000000000 -0600
@@ -54,0 +55 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.core.api)
@@ -68,0 +70 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.gui.api)
@@ -79,0 +82 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.analysis.api)
This worked fine on compile, creating the same output as the SIPMacros.cmake
edit. Each SIP_EXTRA_OPTIONS could be wrapped with a conditional based on a
compile option for generating the APIs.
1) Could you submit your patch via github? If it is a cmake
conditional compilation I see no reason to exclude it from master -
others may have a different opinion.
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....
Regards
Tim
Post by Larry Shaffer
Regards,
Larry Shaffer
Dakota Cartography
Black Hills, South Dakota
[0] http://dl.dropbox.com/u/4058089/qgis/CMakeLists.txt
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Tim Sutton - QGIS Project Steering Committee Member (Release? Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.
?* QGIS programming and support services
?* Mapserver and PostGIS based hosting plans
?* FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Tim Sutton
2012-04-09 22:39:42 UTC
Permalink
Hi
Post by G. Allegri
I would seriously consider upgrading the Python console, first of all to
support autocompletion. I suggested the incorporation of QScintilla a couple
of years ago, but it didn't raise much interest.
Sometimes these things take time to gather interest....we have a much
larger python userbase and probably these ideas are more likely to
gain critical mass...
Post by G. Allegri
A few weeks ago I gave a
look to iPython, and it's Qt console [1].
Larry has a very nice simple integrated IDE plugin in the works that
also uses scintilla, which I would like to see become part of QGIS
core, so scintilla is probably a good fit (though I don't know if it
is mutually exclusive of iPython Qt).

Regards

Tim
Post by G. Allegri
giovanni
[1]? http://ipython.org/ipython-doc/dev/interactive/qtconsole.html
Post by Tim Sutton
Hi Larry
Post by Larry Shaffer
Post by Larry Shaffer
Hi,
I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor (or
another based on QScintilla2), you may be interested in installing and
compiling these APIs.
Seems a better approach, instead of changing SIPMacros.cmake, would be in
--- python/CMakeLists_orig.txt??? 2012-02-19 13:41:41.000000000 -0700
+++ python/CMakeLists.txt??? 2012-04-08 21:00:16.000000000 -0600
@@ -54,0 +55 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.core.api)
@@ -68,0 +70 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.gui.api)
@@ -79,0 +82 @@
+set(SIP_EXTRA_OPTIONS ${PYQT4_SIP_FLAGS} -o -a
${CMAKE_BINARY_DIR}/python/qgis.analysis.api)
This worked fine on compile, creating the same output as the SIPMacros.cmake
edit. Each SIP_EXTRA_OPTIONS could be wrapped with a conditional based on a
compile option for generating the APIs.
1) Could you submit your patch via github? If it is a cmake
conditional compilation I see no reason to exclude it from master -
others may have a different opinion.
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....
Regards
Tim
Post by Larry Shaffer
Regards,
Larry Shaffer
Dakota Cartography
Black Hills, South Dakota
[0] http://dl.dropbox.com/u/4058089/qgis/CMakeLists.txt
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Tim Sutton - QGIS Project Steering Committee Member (Release? Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.
?* QGIS programming and support services
?* Mapserver and PostGIS based hosting plans
?* FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================
_______________________________________________
Qgis-developer mailing list
http://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Tim Sutton - QGIS Project Steering Committee Member (Release? Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
?* QGIS programming and support services
?* Mapserver and PostGIS based hosting plans
?* FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================
Larry Shaffer
2012-04-09 23:38:38 UTC
Permalink
Hi Tim,
Post by Tim Sutton
Hi Larry
Post by Larry Shaffer
Post by Larry Shaffer
Hi,
I've successfully generated QScintilla2 API files for the QGIS Python
bindings and utility modules [0]. If you use the Eric4/5 Python editor
(or
Post by Larry Shaffer
Post by Larry Shaffer
another based on QScintilla2), you may be interested in installing and
compiling these APIs.
Seems a better approach, instead of changing SIPMacros.cmake, would be in
...
This worked fine on compile, creating the same output as the
SIPMacros.cmake
Post by Larry Shaffer
edit. Each SIP_EXTRA_OPTIONS could be wrapped with a conditional based
on a
Post by Larry Shaffer
compile option for generating the APIs.
1) Could you submit your patch via github? If it is a cmake
conditional compilation I see no reason to exclude it from master -
others may have a different opinion.
Sure. I'll sync my local master branch and test the edits (since I only
tested builds of 1.7.4, which didn't have qgis.networkanalysis). I don't
see any issue with leaving the changes as is, if the .api files are not
going to be packaged with the target. Generation of the .api files does not
seem to slow down the compilation, as far as I can tell.
Post by Tim Sutton
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).

The IPython console is very powerful, but required compilation of ZeroMQ on
my Mac. I think it would be great to add to Plugin Editor, but a
QScintilla-based PyQGIS console, I think, would be a good first step.

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota

[0]
Loading Image...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120409/a0226851/attachment.html
Larry Shaffer
2012-04-10 06:10:57 UTC
Permalink
Post by Larry Shaffer
Hi Tim,
Post by Tim Sutton
...
2) What I would really *love* is to have QGIS api completion (and
Post by Tim Sutton
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
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] Loading Image...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20120409/8997f0ec/attachment.html
Tim Sutton
2012-04-10 06:15:22 UTC
Permalink
Hi
Post by Larry Shaffer
Hi Tim,
Post by Tim Sutton
...
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
??? 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.
Awesome stuff!
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.
Maybe not needed as a priority if you think you could achieve the same
using your script runner like support in the editor?

Regards

Tim
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
--
Tim Sutton - QGIS Project Steering Committee Member (Release? Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
?* QGIS programming and support services
?* Mapserver and PostGIS based hosting plans
?* FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================
Loading...