class InkscapeDrawing(svgwrite.Drawing):
"""An svgwrite.Drawing subclass which supports Inkscape layers"""
+ INKSCAPE_NAMESPACE = 'http://www.inkscape.org/namespaces/inkscape'
+ SODIPODI_NAMESPACE = 'http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd'
+
def __init__(self, *args, **kwargs):
super(InkscapeDrawing, self).__init__(*args, **kwargs)
'xmlns:inkscape': SVGAttribute('xmlns:inkscape',
anim=False,
types=[],
- const=frozenset(['http://www.inkscape.org/namespaces/inkscape'])),
+ const=frozenset([self.INKSCAPE_NAMESPACE])),
+ 'xmlns:sodipodi': SVGAttribute('xmlns:sodipodi',
+ anim=False,
+ types=[],
+ const=frozenset([self.SODIPODI_NAMESPACE])),
'inkscape:groupmode': SVGAttribute('inkscape:groupmode',
anim=False,
types=[],
'inkscape:label': SVGAttribute('inkscape:label',
anim=False,
types=frozenset(['string']),
- const=[])
+ const=[]),
+ 'sodipodi:insensitive': SVGAttribute('sodipodi:insensitive',
+ anim=False,
+ types=frozenset(['string']),
+ const=[])
}
self.validator.attributes.update(inkscape_attributes)
svg_attributes = set(elements['svg'].valid_attributes)
svg_attributes.add('xmlns:inkscape')
+ svg_attributes.add('xmlns:sodipodi')
elements['svg'].valid_attributes = frozenset(svg_attributes)
g_attributes = set(elements['g'].valid_attributes)
g_attributes.add('inkscape:groupmode')
g_attributes.add('inkscape:label')
+ g_attributes.add('sodipodi:insensitive')
elements['g'].valid_attributes = frozenset(g_attributes)
- self['xmlns:inkscape'] = 'http://www.inkscape.org/namespaces/inkscape'
+ self['xmlns:inkscape'] = self.INKSCAPE_NAMESPACE
+ self['xmlns:sodipodi'] = self.SODIPODI_NAMESPACE
def layer(self, **kwargs):
"""Create an inkscape layer.
svg = InkscapeDrawing('inkscape-test.svg', profile='full', size=(640, 480))
layer = svg.layer(label="Layer one")
+ layer["sodipodi:insensitive"] = "true"
svg.add(layer)
line = svg.line((100, 100), (300, 100),