當前位置: 首頁>>代碼示例>>Python>>正文


Python inkex.addNS方法代碼示例

本文整理匯總了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

    # --------------------------------------------- 
開發者ID:fsmMLK,項目名稱:inkscapeMadeEasy,代碼行數:20,代碼來源:inkscapeMadeEasy_Base.py

示例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)

    # --------------------------------------------- 
開發者ID:fsmMLK,項目名稱:inkscapeMadeEasy,代碼行數:22,代碼來源:inkscapeMadeEasy_Base.py

示例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 
開發者ID:paulh-rnd,項目名稱:TabbedBoxMaker,代碼行數:20,代碼來源:boxmaker.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:22,代碼來源:tag_group.py

示例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. 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:25,代碼來源:tag_group.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:22,代碼來源:tag_linespec.py

示例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. 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:25,代碼來源:tag_linespec.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:25,代碼來源:tag_figure.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:22,代碼來源:tag_spinespec.py

示例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. 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:24,代碼來源:tag_spinespec.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:25,代碼來源:tag_mplmethods.py

示例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. 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:27,代碼來源:tag_mplmethods.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:22,代碼來源:tag_svgitem.py

示例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 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:22,代碼來源:tag_patchspec.py

示例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. 
開發者ID:FlyRanch,項目名稱:figurefirst,代碼行數:25,代碼來源:tag_patchspec.py


注:本文中的inkex.addNS方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。