[Qgis-developer] Developing Init Python Scripts for Forms - Reloading?

Larry Shaffer larrys at dakotacarto.com
Tue Jun 26 18:05:49 PDT 2012


Hi Andreas,

On Sun, Jun 24, 2012 at 3:05 AM, Andreas Neumann <a.neumann at carto.net> wrote:
> Hi Martin,
>
> Thanks - this helps a lot. Yes - most of the scripts are just in one class.
>

Just a quick note that I have finished support for browsing, editing,
and reloading of custom feature forms and their init scripts, from
within QGIS, in my plugin, Plugin Editor [0]. I hope to do an early
release next week (Mac-, Linux-only).

I would appreciate any testing of editing/reloading of custom feature
forms init scripts, especially complex ones like you mention, Andreas.
I don't generally use them and need to do more testing.

*Does anyone have a project file with data, and a lot of forms and
init scripts that they could share?*

Currently the reloading method used is the same as what Martin
suggested. I will be trying to integrate a customized reloader.py
module, with dependency tracking, etc. [1] with this function as well.

[0] http://dl.dropbox.com/u/4058089/qgis/feature-forms_8b.png
[1] http://osgeo-org.1560.n6.nabble.com/Changes-to-python-utils-py-td4977090.html

>
> Am 23.06.2012 22:04, schrieb Martin Dobias:
>> Hi Andreas
>>
>> On Wed, Jun 20, 2012 at 4:06 PM, Andreas Neumann <a.neumann at carto.net> wrote:
>>> Hi,
>>>
>>> I am developing a rather complex form init script. During development I
>>> would like to reload the code for testing/debugging. However, I always have
>>> to fully close and reopen QGIS until the code is refreshed.
>>>
>>> For plugins there is the plugin reloader. Is there similar refresh
>>> functionality for the form init scripts?
>>
>> If your script is contained just in one script, then it should be
>> sufficient to use this statement in python console each time you need
>> to reload the init script:
>>>>> reload(my_module_name)
>>
>> Before calling the reload first time, make sure to import the module
>> also to the python console:
>>>>> import my_module_name
>>
>> Hope that helps. Reloading in case your script consists of multiple
>> files might be tricky and a better idea would be to restart qgis. In
>> future there could be a feature for automatic reloads, but that would
>> require dependency and module timestamp checking...
>>
>> Martin

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota


More information about the Qgis-developer mailing list