Developing Init Python Scripts for Forms - Reloading?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Developing Init Python Scripts for Forms - Reloading?

Andreas Neumann-4
 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?

 Thanks for any hints,
 Andreas

--
 --
 Andreas Neumann
 Böschacherstrasse 10A
 8624 Grüt (Gossau ZH)
 Switzerland
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Developing Init Python Scripts for Forms - Reloading?

mbernasocchi

Did the same as you a while ago and couldn't find a solution :(
On the bright side it makes you pay attention to program well ;)
Ciao

Marco Bernasocchi (mobile)
http://opengis.ch

On Jun 20, 2012 4:07 PM, "Andreas Neumann" <[hidden email]> 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?

Thanks for any hints,
Andreas

--
--
Andreas Neumann
Böschacherstrasse 10A
8624 Grüt (Gossau ZH)
Switzerland
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Developing Init Python Scripts for Forms - Reloading?

Martin Dobias
In reply to this post by Andreas Neumann-4
Hi Andreas

On Wed, Jun 20, 2012 at 4:06 PM, Andreas Neumann <[hidden email]> 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
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Developing Init Python Scripts for Forms - Reloading?

Andreas Neumann-4
Hi Martin,

Thanks - this helps a lot. Yes - most of the scripts are just in one class.

Your hint saves me quite some time!

Thank you,
Andreas

Am 23.06.2012 22:04, schrieb Martin Dobias:

> Hi Andreas
>
> On Wed, Jun 20, 2012 at 4:06 PM, Andreas Neumann <[hidden email]> 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

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Developing Init Python Scripts for Forms - Reloading?

Larry_S
Hi Andreas,

On Sun, Jun 24, 2012 at 3:05 AM, Andreas Neumann <[hidden email]> 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 <[hidden email]> 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
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer