本文整理汇总了Python中inkex.addNS方法的典型用法代码示例。如果您正苦于以下问题:Python inkex.addNS方法的具体用法?Python inkex.addNS怎么用?Python inkex.addNS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inkex
的用法示例。
在下文中一共展示了inkex.addNS方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getDefinitions
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def getDefinitions(self):
""" retrieves the Defs element of the svg file.
This function returns the element Defs of the current svg file. This elements stores the definition (e.g. marker definition)
if no Defs can be found, a new empty Defs is created
:returns: the defs element
:rtype: etree element
"""
defs = self.getElemFromXpath('/svg:svg//svg:defs')
if defs is None:
defs = inkex.etree.SubElement(self.document.getroot(), inkex.addNS('defs', 'svg'))
return defs
# ---------------------------------------------
示例2: unifyDefs
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def unifyDefs(self):
"""Unify all <defs> nodes in a single <defs> node.
:returns: None
:rtype: -
.. note:: This function does not check whether the ids are unique
"""
root = self.getElemFromXpath('/svg:svg')
mainDef = self.getDefinitions()
for d in root.findall('.//svg:defs', namespaces=inkex.NSS):
if d != mainDef:
for child in d:
mainDef.append(child)
if child.tag == inkex.addNS('g', 'svg') or child.tag == 'g':
self.ungroup(child)
d.getparent().remove(d)
# ---------------------------------------------
示例3: getCircle
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def getCircle(r, c):
(cx, cy) = c
log("putting circle at (%d,%d)" % (cx,cy))
circle = inkex.PathElement.arc((cx, cy), r)
circle.style = { 'stroke': '#000000', 'stroke-width': str(linethickness), 'fill': 'none' }
# ell_attribs = {'style':simplestyle.formatStyle(style),
# inkex.addNS('cx','sodipodi') :str(cx),
# inkex.addNS('cy','sodipodi') :str(cy),
# inkex.addNS('rx','sodipodi') :str(r),
# inkex.addNS('ry','sodipodi') :str(r),
# inkex.addNS('start','sodipodi') :str(0),
# inkex.addNS('end','sodipodi') :str(2*math.pi),
# inkex.addNS('open','sodipodi') :'true', #all ellipse sectors we will draw are open
# inkex.addNS('type','sodipodi') :'arc',
# 'transform' :'' }
#inkex.etree.SubElement(parent, inkex.addNS('path','svg'), ell_attribs )
return circle
示例4: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--name" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#import matplotlib
#Define string option "--name" with "-n" shortcut and default value "World".
self.arg_parser.add_argument('-n', '--name', action = 'store',
type = str, dest = 'name', default = 'none',
help = 'Name group')
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例5: effect
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def effect(self):
"""
Effect behaviour.
Overrides base class' method and inserts "Hello World" text into SVG document.
"""
# Get script's "--what" option value.
name = self.options.name
# Get access to main SVG document element and get its dimensions.
svg = self.document.getroot()
# or alternatively
# Create text element
if len(self.svg.selected.values())>1:
raise Exception('too many items')
else:
el = list(self.svg.selected.values())[0]
newElm = etree.Element(inkex.addNS("group", "figurefirst"))
newElm.attrib[inkex.addNS("name", "figurefirst")] = name
#print inkex.NSS
el.append(newElm)
# Create effect instance and apply it.
示例6: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--name" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#import matplotlib
#Define string option "--name" with "-n" shortcut and default value "World".
self.arg_parser.add_argument('-n', '--name', action = 'store',
type = str, dest = 'name', default = 'none',
help = 'Name linespec')
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例7: effect
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def effect(self):
"""
Effect behaviour.
Overrides base class' method and inserts "Hello World" text into SVG document.
"""
# Get script's "--what" option value.
name = self.options.name
# Get access to main SVG document element and get its dimensions.
svg = self.document.getroot()
# or alternatively
# Create text element
if len(self.svg.selected.values())>1:
raise Exception('too many items')
else:
el = list(self.svg.selected.values())[0]
newElm = etree.Element(inkex.addNS("linespec", "figurefirst"))
newElm.attrib[inkex.addNS("name", "figurefirst")] = name
#print inkex.NSS
el.append(newElm)
# Create effect instance and apply it.
示例8: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--name" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#import matplotlib
#Define string option "--name" with "-n" shortcut and default value "World".
self.arg_parser.add_argument('-n', '--name', action = 'store',
type =str, dest = 'name', default = 'none',
help = 'Name figure')
self.arg_parser.add_argument('-t', '--template', action = 'store',
type = str, dest = 'template', default = 'none',
help = 'Name template (optional)')
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例9: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--spinespec" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#import matplotlib
#Define string option "--spinespec" with "-sp" shortcut and default value "left,bottom".
self.arg_parser.add_argument('-s', '--spinespec', action = 'store',
type =str, dest = 'spinespec', default = 'left,bottom',
help = "Add a spine specification as a comma separated list of spine locations. \n Valid values are: top,bottom,right or left")
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例10: effect
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def effect(self):
"""
Effect behaviour.
"""
# Get script's "--what" option value.
spinelist = self.options.spinespec
# Get access to main SVG document element and get its dimensions.
svg = self.document.getroot()
# or alternatively
# Create text element
if len(self.svg.selected.values())>1:
raise Exception('too many items')
else:
el = list(self.svg.selected.values())[0]
newElm = etree.Element(inkex.addNS("spinespec", "figurefirst"))
newElm.attrib[inkex.addNS("spinelist", "figurefirst")] = spinelist
#print inkex.NSS
el.append(newElm)
# Create effect instance and apply it.
示例11: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--name" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#Define string option "--mplmethod" with "-m" shortcut and default value "none".
self.arg_parser.add_argument('-m', '--mplmethod', action = 'store',
type = str, dest = 'mplmethod', default = 'none',
help = 'Method name')
#Define string option "--mplmethodarg" with "-z" shortcut and default value "none".
self.arg_parser.add_argument('-a', '--mplmethodarg', action = 'store',
type = str, dest = 'mplmethodarg', default = 'none',
help = 'Method arguments')
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例12: effect
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def effect(self):
"""
Effect behaviour.
Overrides base class' method and inserts figurefirst:mplmethods node into SVG document,
with figurefirst:mplmethod, mplmethodarg attribute, value pair.
"""
# Get script's "--what" option value.
mplmethod = self.options.mplmethod
mplmethodarg = self.options.mplmethodarg
# Get access to main SVG document element and get its dimensions.
svg = self.document.getroot()
# or alternatively
# Create text element
if len(self.svg.selected.values())>1:
raise Exception('too many items')
else:
el = list(self.svg.selected.values())[0]
newElm = etree.Element(inkex.addNS("mplmethods", "figurefirst"))
newElm.attrib[inkex.addNS(mplmethod, "figurefirst")] = mplmethodarg
#print inkex.NSS
el.append(newElm)
# Create effect instance and apply it.
示例13: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--name" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#import matplotlib
#Define string option "--name" with "-n" shortcut and default value "World".
self.arg_parser.add_argument('-n', '--name', action = 'store',
type = str, dest = 'name', default = 'none',
help = 'Name svgitem')
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例14: __init__
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def __init__(self):
"""
Constructor.
Defines the "--name" option of a script.
"""
# Call the base class constructor.
inkex.Effect.__init__(self)
#import matplotlib
#Define string option "--name" with "-n" shortcut and default value "World".
self.arg_parser.add_argument('-n', '--name', action = 'store',
type = str, dest = 'name', default = 'none',
help = 'Name patch')
inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/"
try:
etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/")
except AttributeError:
#inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst"))
#This happens on windows version of inkscape - it might be good to check
#and see if the namespace has been correctly added to the document
pass
示例15: effect
# 需要导入模块: import inkex [as 别名]
# 或者: from inkex import addNS [as 别名]
def effect(self):
"""
Effect behaviour.
Overrides base class' method and inserts "Hello World" text into SVG document.
"""
# Get script's "--what" option value.
name = self.options.name
# Get access to main SVG document element and get its dimensions.
svg = self.document.getroot()
# or alternatively
# Create text element
if len(self.svg.selected.values())>1:
raise Exception('too many items')
else:
el = list(self.svg.selected.values())[0]
newElm = etree.Element(inkex.addNS("patchspec", "figurefirst"))
newElm.attrib[inkex.addNS("name", "figurefirst")] = name
#print inkex.NSS
el.append(newElm)
# Create effect instance and apply it.