当前位置: 首页>>代码示例>>Python>>正文


Python DOM.getAttribute方法代码示例

本文整理汇总了Python中pyjamas.DOM.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getAttribute方法的具体用法?Python DOM.getAttribute怎么用?Python DOM.getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.DOM的用法示例。


在下文中一共展示了DOM.getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getProperty

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def getProperty(obj, propertyName):
    """
    Reads an object given a property and returns it as a JavaScriptObject

    @param object
    @param propertyName
    @return the object
    """
    DOM.getAttribute(obj, propertyName)
开发者ID:luiseduardohdbackup,项目名称:pyjs,代码行数:11,代码来源:Range.py

示例2: pygwt_processMetas

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def pygwt_processMetas():
    from pyjamas import DOM
    metas = doc().getElementsByTagName("meta")
    for i in range(metas.length):
        meta = metas.item(i)
        name = DOM.getAttribute(meta, "name")
        if name == "pygwt:module":
            content = DOM.getAttribute(meta, "content")
            if content:
                pygwt_moduleNames.append(content)
    return pygwt_moduleNames
开发者ID:audreyr,项目名称:pyjs,代码行数:13,代码来源:__pyjamas__.py

示例3: createWidgetOnElement

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def createWidgetOnElement(element):
    fc = DOM.getAttribute(element, 'id')
    lbr = fc.find("(")
    klsname = fc[:lbr]
    txtargs = fc[lbr+1:-1]
    args = []
    kwargs = {}
    for arg in txtargs.split(','):
        findeq = arg.find('=')
        if findeq == -1:
            args.append(arg)
        else:
            k = arg[:findeq]
            v = arg[findeq+1:]
            if ((v[0] == "'" and v[-1] == "'") or
                (v[0] == '"' and v[-1] == '"')):
                # string - strip quotes
                v = v[1:-1]
            else:
                # assume it's an int
                v = int(v)
            kwargs[k] = v

    kwargs['Element'] = element
    return lookupClass(klsname)(*args, **kwargs)
开发者ID:Afey,项目名称:pyjs,代码行数:27,代码来源:Factory.py

示例4: identify

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def identify(self, element):
     if element.nodeType != 1:
         return False
     if str(string.lower(element.tagName)) != 'span':
         return False
     style = DOM.getAttribute(element, "className")
     return style and style.startswith("editor-")
开发者ID:Afey,项目名称:pyjs,代码行数:9,代码来源:RichTextToolbar.py

示例5: setStyleName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def setStyleName(element, style, add):

    oldStyle = DOM.getAttribute(element, "className")
    if oldStyle is None:
        oldStyle = ""
    idx = oldStyle.find(style)

    # Calculate matching index
    lastPos = len(oldStyle)
    while idx != -1:
        if idx == 0 or (oldStyle[idx - 1] == " "):
            last = idx + len(style)
            if (last == lastPos) or ((last < lastPos) and (oldStyle[last] == " ")):
                break
        idx = oldStyle.find(style, idx + 1)

    if add:
        if idx == -1:
            DOM.setAttribute(element, "className", oldStyle + " " + style)
    else:
        if idx != -1:
            if idx == 0:
              begin = ''
            else:
              begin = oldStyle[:idx-1]
            end = oldStyle[idx + len(style):]
            DOM.setAttribute(element, "className", begin + end)
开发者ID:anandology,项目名称:pyjamas,代码行数:29,代码来源:UIObject.py

示例6: drawImage

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
    def drawImage(self, img, *args):
        # create an image element:
        # <image xlink:href="firefox.jpg" x="0" y="0" height="50px" width="50px"/>
        # The way to do this is to create a clipping container and place the image inside that,
        # using scaling and positioning to approximate some of the effect of sourceXY and destXY
        # for now, we ignore all this
        #
        # get the image size and URL - image may be a Image Widget or an <img> Element
        if isinstance(img, Widget):     # Image widget
            img_elem = img.getElement()
            url = img.getUrl()
        else:   # <img> element
            img_elem = img
            url = DOM.getAttribute(img, "src")
        # determine all parms
        sourceXY = None
        sourceWH = None
        destXY = None
        destWH = None
        # get the parms that are specified
        if len(args) == 8:  # all parms specified
            sourceXY = (args[0], args[1])
            sourceWH = (args[2], args[3])
            destXY = (args[4], args[5])
            destWH = (args[6], args[7])
        elif len(args) == 4:    # only destXY and destWH are specified
            destXY = (args[0], args[1])
            destWH = (args[2], args[3])
        elif len(args) == 2:    # we just get destXY
            destXY = (args[0], args[1])
            # by default we keep the same size
            destWH = (img_elem.width, img_elem.height)
        else:
            raise TypeError("Wrong number of arguments for SVGCanvas.drawImage")

        # sourceWH and destWH determine the scaling
        # sourceXY and scaling determine where to place the image inside the clipping container
        # destXY determines where to place the clipping container

        # for now just create an SVG image element:
        # <image xlink:href="firefox.jpg" x="0" y="0" height="50px" width="50px"/>
#        print 'Create: <image xlink:href="'+url+'" x="'+str(destXY[0])+'" y="'+str(destXY[1])+'" height="'+str(destWH[1])+'px" width="'+str(destWH[0])+'px"/>'
        image = self._createElementSVG("image")
        # set the URL
        image.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", url); 
        # set the pos/dimensions
        DOM.setElemAttribute(image, "x", str(int(destXY[0])))
        DOM.setElemAttribute(image, "y", str(int(destXY[1])))
        DOM.setElemAttribute(image, "width", str(int(destWH[0])))
        DOM.setElemAttribute(image, "height", str(int(destWH[1])))
        # add the element to the canvas
        self._addElementSVG(image)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:54,代码来源:SVGCanvas.py

示例7: getEventTargetCell

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
    def getEventTargetCell(self, event):
        td = DOM.eventGetTarget(event)
        while td is not None:
            if DOM.getAttribute(td, "tagName").lower() == "td":
                tr = DOM.getParent(td)
                body = DOM.getParent(tr)
                if DOM.compare(body, self.bodyElem):
                    return td
            if DOM.compare(td, self.bodyElem):
                return None
            td = DOM.getParent(td)

        return None
开发者ID:andreyvit,项目名称:pyjamas,代码行数:15,代码来源:HTMLTable.py

示例8: getElementById

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def getElementById(element, id):
    try:
        element_id = DOM.getAttribute(element, "id")
    except:
        element_id = None
    if element_id is not None and element_id == id:
        return element

    child = DOM.getFirstChild(element)
    while child is not None:
        ret = getElementById(child, id)
        if ret is not None:
            return ret
        child = DOM.getNextSibling(child)

    return None
开发者ID:certik,项目名称:pyjamas,代码行数:18,代码来源:HTMLPanel.py

示例9: setDragImage

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def setDragImage(self, element, x, y):
     position_absolute = DOM.getStyleAttribute(element,
                                 'position') == 'absolute'
     if position_absolute:
         self.dragLeftOffset = x + DOM.getAbsoluteLeft(
                 element.offsetParent)
         self.dragTopOffset = y + DOM.getAbsoluteTop(
                 element.offsetParent)
     else:
         self.dragLeftOffset = x
         self.dragTopOffset = y
     if element.tagName.lower().endswith('img'):
         src = DOM.getAttribute(element,'src')
         element = DOM.createElement('img')
         DOM.setAttribute(element, 'src', src)
     if not self.draggingImage:
         self.createDraggingImage(element)
     else:
         self.draggingImage.setImage(element)
开发者ID:Afey,项目名称:pyjs,代码行数:21,代码来源:DNDHelper.py

示例10: onDragStart

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     target = Widget(Element=target)
     try:
         id = target.getID()
     except:
         id = ''
     if id == 'datadrag0':
         dt.setData('text/plain', 'Hello World!')
     elif id == 'datadrag1':
         logo = doc().getElementById('logo')
         logo_parent_element = DOM.getParent(logo)
         text = DOM.getInnerText(logo_parent_element)
         html = DOM.getInnerHTML(logo_parent_element)
         uri = DOM.getAttribute(logo, 'src')
         dt.setData('text/plain', text)
         dt.setData('text/html', html)
         dt.setData('text/uri-list', uri)
     elif id == 'datadrag2':
         dt.setData('x-star-trek/tribble', 'I am a tribble')
开发者ID:anandology,项目名称:pyjamas,代码行数:23,代码来源:DNDTest.py

示例11: getStyleName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def getStyleName(self, row, column):
     return DOM.getAttribute(self.getElement(row, column), "className")
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:4,代码来源:CellFormatter.py

示例12: getAttr

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def getAttr(self, row, column, attr):
     elem = self.getElement(row, column)
     return DOM.getAttribute(elem, attr)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:5,代码来源:CellFormatter.py

示例13: getText

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def getText(self):
     return DOM.getAttribute(self.getElement(), "value")
开发者ID:nielsonsantana,项目名称:pyjs,代码行数:4,代码来源:TextBoxBase.py

示例14: getName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
 def getName(self):
     return DOM.getAttribute(self.getElement(), "name")
开发者ID:nielsonsantana,项目名称:pyjs,代码行数:4,代码来源:TextBoxBase.py

示例15: getValue

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
    def getValue(self, index):
        self.checkIndex(index)

        option = DOM.getChild(self.getElement(), index)
        return DOM.getAttribute(option, "value")
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:ListBox.py


注:本文中的pyjamas.DOM.getAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。