[Qgis-developer] PyQGIS Dev Lib plugin idea

Larry Shaffer larrys at dakotacarto.com
Mon Apr 2 16:08:37 EDT 2012


Hi,

I have an idea that I am not sure has been discussed before:

How about a core, or install-able, plugin that consists of reusable
Python functions and subclass-able PyQt widgets?

I envision this plugin containing community-submitted functions and
classes that any Python plugin dev can call or instantiate from their
plugin. This would help plugin devs from reinventing the wheel for
many common tasks, offer reusable custom or common widgets, and
possibly standardize some user interface widgets across plugins.

Here are some plugin components that might be in such a dev lib:

* Syntax-highlighted text editor

* Syntax-highlighted SQL, regex, etc. edting widgets

* Tree widget class that collects and displays all legend layers (with
filtering)

* Any other custom widget that could be made PyQt subclass-able (QGIS
browser, etc.?)

* Common routines for editing/importing/exporting layers or their features

* Routines for interacting with the PyQGIS console, logging, etc.

* Any routine, portable package, or widget that is stable, helpful to
other plugin devs, and/or just plain reduces code redundancy

This is similar to the snippets section of plugin.qgis.org, but
embedded in QGIS and importable into plugins, like the qgis.utils
module or like calling a method of an installed plugin (e.g.
sys.modules[plugin_package_name].method() ). Might be most helpful to
have the plugin dev lib package referenced to a single object by
qgis.utils module, similar to 'iface' (maybe 'devlib'?). Then...

self.editor = qgis.utils.devlib.text_editors.TextEditor(file_path, parent=self)

... would yield a complete text editor widget with loaded file.

Running the lib plugin directly might yield a gui, listing available
functions and classes with their docstrings displayed, showing a
plugin dev the API to available components (generated by Sphinx).

Submitting code to such a dev lib plugin should have some oversight,
like submitting to the official plugin repository. All submitted code
might be required to have a supplied unit test (or at least a doctest)
and translatable strings. There should probably be noted minimum QGIS,
Python, PyQt or Qt versions and imported modules required to use the
code.

Part of the dev lib might also include common icons and other
resources as importable modules. Maybe useful for standardizing icons,
etc.

Any opinions on this idea? Any suggestions on a preferred implementation?

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota


More information about the Qgis-developer mailing list