Loading and modifying svg within Inkscape plugin

I am currently writing an Inkscape plugin using Python. Within this plugin, I would like to load a template (an existing svg) from the plugin folder and access some objects within this template by name or key. Then I would like to change the border and/or fill color of the object and add some text to it. How would I do this using the python scripting interface of inkscape? I found just a few examples (see below) on how to write a plugin for inkscape, but they all work on existing, already opened documents.

  • http://www.hoboes.com/Mimsy/hacks/write-inkscape-extension-create-multiple-duplicates/
  • http://wiki.inkscape.org/wiki/index.php/Script_extensions
  • http://ospublish.constantvzw.org/blog/tools/inkscape-plugins-in-python
  • http://wiki.inkscape.org/wiki/index.php/Generating_objects_from_extensions
  • http://wiki.inkscape.org/wiki/index.php/PythonEffectTutorial

  • Can you use lxml?

    t = etree.parse("path/test.xml")
    

    You could then either

  • manipulate the properties of t directly -- this can be done from python without actually opening inkscape. Your tree could be saved with t.write("filename")
  • add t to the currently open document using self.document.getroot().append(t)
  • Also, this is not what you asked for, but may come in useful: an inkscape plugin that allows you to write short python snippets from within Inkscape: http://www.smanohar.com/inkscape.php

    链接地址: http://www.djcxy.com/p/56946.html

    上一篇: 将inkscape svg转换为raphael问题

    下一篇: 在Inkscape插件中加载和修改svg