[Qgis-developer] Python support in project file
larrys at dakotacarto.com
Wed May 23 15:38:32 PDT 2012
On Wed, May 23, 2012 at 1:24 PM, Giuseppe Sucameli <brush.tyler at gmail.com>wrote:
> Hi all,
> I started to work on adding python support in project files (see ).
> I've added a new tab "Project routines" to the project properties dialog
> where the user can define 3 different python routines:
> one is executed when the project is loaded,
> the next one when the project is saved,
> and the last one when the project is closed (saved or not).
> I'm also adding a safe-check, it asks to the user if enabling them.
> I've few questions:
> 1. In  Martin wrote: """The routines should be able to access QGIS
> application with the use of the interface in the same way how plugins
> I'm wondering if those routines must be functions with a specific signature
> or they could just access the QGis interface using the qgis.utils.iface
> since I'll use the QgsPythonRunner to run them.
> 2. In a loaded project with trusted scripts (the user has trusted them)
> if the user changes their definitions from project properties dialog
> 2.a. should the new routines become active immediately when the user
> clicks on the apply button in the project properies dialog,
> 2.b. or should become active when he saves the project (the new
> projectSaved script has to be called just after the project is saved),
> 2.c. or should I keep the previous ones until the project is reloaded?
> 3. should I call them project-embedded-scripts or routines??? :)
> Opinions are welcome.
I apologize for posting before you have had your questions answered. This
is an interesting feature and I have a question and suggestion for you.
1) Will the scripts/routines actually be embedded in the project file, or
be as sidecar file(s)? I'm looking at adding editing access to code in my
Plugin Editor plugin.
2) How about offering plugins the ability to programatically 'add'
themselves to a project's open/save/close event? (In addition to running
Plugins could have standardized method 'hooks' (i.e. slots like initGui)
for each event and only need to register with the user and the project's
settings. There could be a small table listing all plugins found to offer
hooks for each event, with a enabling checkbox next to them (3 tables or 1
with mixed events).
When a user installs or launches a plugin, it could check it's enabled
state for a project event and prompt user to authenticate its adding or
toggling for that event. This would allow plugin authors to add their
plugins to the project's events without requiring a user to write any code,
and allow the user to toggle a plugin's hook on/off/ignore, or deny a
plugin's request. Plugin authors would then have to handle user
decisions/settings, and not annoy users with dialogs at every project event.
This is different than the plugin responding to any project's
open/save/close Qt signal (only open is supported now in API?), and/or a
plugin saving a setting in the project file, as it introduces standardized
user preference and authentication across all plugins wanting access to a
Black Hills, South Dakota
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Qgis-developer