[Qgis-developer] Python support in project file

Martin Dobias wonder.sk at gmail.com
Wed May 30 23:30:13 PDT 2012


On Thu, May 31, 2012 at 2:49 AM, Giuseppe Sucameli <sucameli at faunalia.it> wrote:
>> How the GUI is going to look like? Should the user enter the Python
>> code directly into some text edit widgets?
>
> yes, 3 text edit widget, one for each macro.
> The user has to write python code into them.

I would prefer to have just one edit widget with all macros inside.
With 3 text edit widgets it would be complicated to have some common
utility functions, module imports etc. With one edit widget there
could the three predefined functions called by QGIS:

def openProject(...):
  pass
def saveProject(...):
  pass
def closeProject(...):
  pass

Like this it would be easier to add custom imports, utility function
and it would be simpler to navigate the code (if there are more than
just few lines).


>> How are you going to save the python code? In an external file or
>> embedded into XML file or even something else?
>
> I would save it into the project (embedded in the XML) until we will
> have a different way to pack project and related stuff together.

Ok - hopefully XML will not choke python indentation :)


> BTW one popup only would be needed, i.e. the project is loaded.
> If the user trust macros then they become active and ready to be
> executed.

See Nathan's post - he better explains what I have meant.


> For you macros should be like a plugin embedded in the project file,
> so load and unload method, enabled asynchronously, ... (am I right?)
> I guess in that case it doesn't matter if the project saved macro exists,
> it could be just a iface signal the embedded-plugin load method
> connects itself to.
>
> For me they are project macros, hence strictly related to the project
> events, i.e not a plugin but slots (routines) connected to signals (project
> events), it has to be enabled synchronously and then a project saved
> macro makes sense.
>
> Project plugin VS. Project macros:
> there's a difference, even although it seems more theoretical than
> practical :-)

For me the project macros are really not that different from plugins -
they have just different lifetimes.

Regards
Martin


More information about the Qgis-developer mailing list