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


Python DOM.setAttribute方法代码示例

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


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

示例1: updateState

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def updateState(self):
     if self.disclosurePanel.getOpen():
         DOM.setAttribute(self.imgElem, "src",
                          self.imageBase + "disclosurePanelOpen.png")
     else:
         DOM.setAttribute(self.imgElem, "src",
                          self.imageBase + "disclosurePanelClosed.png")
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:9,代码来源:DisclosurePanel.py

示例2: setCellHorizontalAlignment

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def setCellHorizontalAlignment(self, widget, align):
     td = self.getWidgetTd(widget)
     if td is not None:
         if align is None:
             DOM.removeAttribute(td, "align")
         else:
             DOM.setAttribute(td, "align", align)
开发者ID:Afey,项目名称:pyjs,代码行数:9,代码来源:CellPanel.py

示例3: onDragStart

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def onDragStart(self, event):
     dt = event.dataTransfer
     target = DOM.eventGetTarget(event)
     target = Widget(Element=target)
     id = target.getID()
     dt.setData("Text", "Dropped %s" % target.getID())
     dt.effectAllowed = 'copy'
     if id == 'imgdrag1':
         parent = self.getParent()
         while not hasattr(parent, 'h2'):
             parent = parent.getParent()
         dt.setDragImage(parent.h2.getElement(), 10, 10)
     elif id == 'imgdrag2':
         dt.setDragImage(doc().getElementById('logo'), 10, 10)
     elif id == 'imgdrag3':
         # OK, it's a bit of a cheat, but the following works on current
         # Opera, IE, Firefox, Safari, Chrome.
         ctx = GWTCanvas(50, 50)
         self.makeCanvasImg(ctx)
         try:
             img = DOM.createImg()
             DOM.setAttribute(img, 'src', ctx.canvas.toDataURL())
             dt.setDragImage(img, 25, 25)
         except:
             dt.setDragImage(ctx.canvas, 25, 25)
开发者ID:anandology,项目名称:pyjamas,代码行数:27,代码来源:DNDTest.py

示例4: makeBox

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
    def makeBox(self, label):
        wrapper = VerticalPanel(BorderWidth=1)
        wrapper.add(HTML(label))
        DOM.setAttribute(wrapper.getTable(), "cellPadding", "10")
        DOM.setAttribute(wrapper.getTable(), "bgColor", "#C3D9FF")

        return wrapper
开发者ID:Afey,项目名称:pyjs,代码行数:9,代码来源:absolutePanel.py

示例5: setStyleName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [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: setName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def setName(self, name):
     if name is None:
         #throw new NullPointerException("Name cannot be null");
         console.error("Name cannot be null")
     elif len(name) == 0:
         #throw new IllegalArgumentException("Name cannot be an empty string.");
         console.error("Name cannot be an empty string.")
     DOM.setAttribute(self.getElement(), "name", name)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:10,代码来源:Hidden.py

示例7: setName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def setName(self, name):
     if name is None:
         raise ValueError("Name cannot be null")
         console.error("Name cannot be null")
     elif len(name) == 0:
         raise ValueError("Name cannot be an empty string.")
         console.error("Name cannot be an empty string.")
     DOM.setAttribute(self.getElement(), "name", name)
开发者ID:Afey,项目名称:pyjs,代码行数:10,代码来源:Hidden.py

示例8: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def __init__(self, **kwargs):
     if not kwargs.has_key('StyleName'): kwargs['StyleName']="gwt-FileUpload"
     if kwargs.has_key('Element'):
         element = kwargs.pop('Element')
     else:
         element = DOM.createElement("input")
     DOM.setAttribute(element, "type", "file")
     self.setElement(element)
     Widget.__init__(self, **kwargs)
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:11,代码来源:FileUpload.py

示例9: drawImage

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
    def drawImage(self, mode):
        if mode == "white":
            src = tree_white
        elif mode == "open":
            src = tree_open
        elif mode == "closed":
            src = tree_closed

        DOM.setAttribute(self.imgElem, "src", src)
开发者ID:audreyr,项目名称:pyjs,代码行数:11,代码来源:TreeItem.py

示例10: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def __init__(self, disclosurePanel, **kwargs):
     element = kwargs.pop('Element', DOM.createAnchor())
     SimplePanel.__init__(self, element)
     self.disclosurePanel = disclosurePanel
     element = self.getElement()
     DOM.setAttribute(element, "href", "javascript:void(0);");
     DOM.setStyleAttribute(element, "display", "block")
     self.sinkEvents(Event.ONCLICK)
     self.setStyleName("header")
开发者ID:anandology,项目名称:pyjamas,代码行数:11,代码来源:DisclosurePanel.py

示例11: setStyleName

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def setStyleName(self, element, style=None, add=True):
     """When called with a single argument, this replaces all the CSS classes
     associated with this UIObject's element with the given parameter.  Otherwise,
     this is assumed to be a worker function for addStyleName and removeStyleName."""
     # emulate setStyleName(self, style)
     if style is None:
         style = element
         DOM.setAttribute(self.element, "className", style)
         return
     setStyleName(element, style, add)
开发者ID:andreyvit,项目名称:pyjamas,代码行数:12,代码来源:UIObject.py

示例12: score

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
 def score(self,score,houses):
     score =  j_p.encode(score)
     houses =  j_p.encode(houses)
     DOM.setAttribute(self.scored,"value",score)
     DOM.setAttribute(self.housed,"value",houses)
     #self.talk(str((score,houses)))
     frm = self.__form
     JS("""
         frm.submit()
     """)
     #self.__form.submit()
     return score
开发者ID:labase,项目名称:jeppeto,代码行数:14,代码来源:pyjamas_factory.py

示例13: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
    def __init__(self, name=None, value=None, **kwargs):

        name = kwargs.get("Name", name)
        if name is not None:
            kwargs['Name'] = name
        value = kwargs.get("Value", value)
        if value is not None:
            kwargs['Value'] = kwargs.get("Value", value)
        element = kwargs.pop('Element', None) or DOM.createElement("input")
        self.setElement(element)
        DOM.setAttribute(element, "type", "hidden")

        Widget.__init__(self, **kwargs)
开发者ID:Afey,项目名称:pyjs,代码行数:15,代码来源:Hidden.py

示例14: buildTree

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
    def buildTree(self):
        """ Build the contents of our tree.

            Note that, for now, we highlight the demos which haven't been
            written yet.
        """
        sections = {} # Maps section name to TreeItem object.

        for demo in self._demos:
            if demo['section'] not in sections:
                section = TreeItem('<b>' + demo['section'] + '</b>')
                DOM.setStyleAttribute(section.getElement(),
                                      "cursor", "pointer")
                DOM.setAttribute(section.itemTable, "cellPadding", "0")
                DOM.setAttribute(section.itemTable, "cellSpacing", "1")
                self._tree.addItem(section)
                sections[demo['section']] = section

            section = sections[demo['section']]

            if demo['doc'][:26] == "Documentation goes here...":
                item = TreeItem('<font style="color:#808080">' +
                                demo['title'] + '</font>')
            else:
                item = TreeItem(demo['title'])
            DOM.setStyleAttribute(item.getElement(), "cursor", "pointer")
            DOM.setAttribute(item.itemTable, "cellPadding", "0")
            DOM.setAttribute(item.itemTable, "cellSpacing", "1")
            item.setUserObject(demo)
            section.addItem(item)

        # Open the branches of the tree.

        for section in sections.keys():
            sections[section].setState(True, fireEvents=False)
开发者ID:Afey,项目名称:pyjs,代码行数:37,代码来源:Showcase.py

示例15: initElement

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import setAttribute [as 别名]
    def initElement(self, element, **ka):
        self.inputElem = element
        self.labelElem = DOM.createLabel()
        element = ka.pop('Element', None) or DOM.createSpan()
        ButtonBase.__init__(self, element, **ka)

        self.sinkEvents(Event.FOCUSEVENTS | Event.ONCLICK)

        DOM.appendChild(self.getElement(), self.inputElem)
        DOM.appendChild(self.getElement(), self.labelElem)

        uid = "check%d" % self.getUniqueID()
        DOM.setAttribute(self.inputElem, "id", uid)
        DOM.setAttribute(self.labelElem, "htmlFor", uid)
开发者ID:Afey,项目名称:pyjs,代码行数:16,代码来源:CheckBox.py


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