David Douard wrote:
For now, I am trying to rewrite the inkex.py and all the helper modules so I can write extension scripts the Python way (which I find is not the case today).
What is the "Python way"?
The code I am writing is dependant on numpy, whih I know can be problematic for Inkscape since it would add an external dependancy. However, I nticesd that at least one extension is actually using numpy (that's what decided me to make numpy a preriquisity of my code).
numpy shouldn't be a problem.
I'll publish my code as soon as I have something that I can decently make public. My goal is to make path ans objects manipulations as easy as possible, without having to deal with SVG xml node or so in any way. I want to be able to add paths, etc. I other words, to have a nice object API to create effects easily.
That would be great. One of the original goal was to combine inkex.py with SVG-Utils from programmer-art.org. But I was never able to get the authors to respond to my comments and questions.
http://web.archive.org/web/20041212142734/programmer-art.org/svg-utils
(I had to use opera to open that link because the xml is invalid.)
And you will notice that the project is completely absent from their new site.
It was GPL, you may be interested in using it as a starting point.
One thing I would suggest: don't completely hide the low level XML. Having access is just too too useful. The SVG spec is very large. Inkscape still hasn't implemented it all. If you seek to hide XML from the user you'll have to redo all the work that Inkscape has done and more.
Another project that may help you as you seek to do amazing things is lib2geom. ( http://lib2geom.sourceforge.net/ ) A few of the Inkscape developers have started this project to develop a mathematical engine to back Inkscape. Python bindings have been started but are quite unfinished. You might just want to lend a hand to this project and make your work easier.
However, trying to understand how Python scripting work in Inkscape, I was wondering why the Python interpreter is embedded in the Inkscape executable, according the way Python effects work (simply a Python program that is runned with SVG file in /tmp or so, and with parameters on command line). Why not simply use the Python executable provided by the platform. Any Linux and MacOSX station do have Python installed. In win32, heee, let's ask user to install the Python package if she wants nice scripted effects.
Um, that is how we do it. Everything Inkscape does uses the platform's python interpreter. Well, almost. On win32 we ship python with Inkscape so that the users can use effects right out of the box. You can find more information about extensions on the wiki.
http://wiki.inkscape.org/wiki/index.php/Category:Extensions
If you plan to fix the problems with inkex.py, it might help to write a few extensions with it.
The embedded interpreter that you see is meant to be used for the day when we expose Inkscape's internals to scripting. As the presence of the interpreter would suggest, the work has started. But it isn't finished yet. You may also be interested in helping with this work.
Aaron Spike