本文整理汇总了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")
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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")
示例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)
示例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
示例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)
示例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)
示例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)