[Qgis-developer] PyQGIS Dev Lib plugin idea
Larry Shaffer
larrys at dakotacarto.com
Tue Apr 3 13:08:37 EDT 2012
Hi Martin,
On Tue, Apr 3, 2012 at 1:39 AM, Martin Dobias <wonder.sk at gmail.com> wrote:
> Hi Larry
>
> On Mon, Apr 2, 2012 at 10:08 PM, Larry Shaffer <larrys at dakotacarto.com> wrote:
>> 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.
>
> To me it seems that qgis_gui library would be the best fit for such
> classes since it is supposed to be a library of reusable GUI stuff.
> But I understand that for many people c++ is not an option.
I see your point here. There are some good reusable widgets in the
qgis_gui library I have not used yet in my plugins.
A Python dev library/plugin package would allow for plugin developers
to import pre-designed classes/widgets, which might not be so useful
for the QGIS dev community on a whole (i.e. not 'worth' the effort of
porting to the base C++ libs), but very useful for the 5-10 developers
who do import it. Kind of like a Python virtual environment where pip
has been used to install a diverse set of Python packages for a
particular purpose: to help other Python plugin developers.
>> 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.
>
> You could try to start such a project - create a dev lib plugin,
> create a repository, add some useful widgets... soon you should see if
> there is interest or not. Obviously requiring another plugin will be a
> burden, so another possibility would be that the dev lib would be a
> python package inside a plugin (that would demo the functionality) and
> other developers would just copy the whole package to their plugins
> (or just some bits from it).
Yes, starting this as a separate plugin seems like the right first
step. It's not ideal to to have users install a requisite plugin to
use another plugin, but this is how shared libs work (e.g. linux
package manager). May be best as a regular plugin, especially if it
significantly grows, since the plugin installer already handles
updates.
Running the dev plugin, in addition to listing the widgets, etc.,
might also demo them, as you suggested. The copy/paste function might
be a good fit for some widgets/routines, and could be a fallback
choice for all, especially useful for devs who don't want to import
from another plugin.
Maybe 'Widget/Snippet Library' is a better name for such a plugin. It
could also have a section where it pulls down the current, un-vetted
snippets listed at plugins.qgis.org.
> Such dev lib could work also as an incubator for widgets - some
> widgets that prove to be useful may be picked by core team and ported
> to qgis_gui library (with python bindings).
Yes, this makes a lot of sense. Anything heavily reused by plugin
developers points towards something possibly worth porting to the base
libs. This could be ascertained now, with an audit of existing plugin
code. Redundant patterns of plugin development may not be apparent to
most developers, unless they have written several plugins.
Regards,
Larry Shaffer
Dakota Cartography
Black Hills, South Dakota
More information about the Qgis-developer
mailing list