本文整理汇总了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)
示例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
示例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)
示例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-")
示例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)
示例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)
示例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
示例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
示例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)
示例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')
示例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")
示例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)
示例13: getText
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def getText(self):
return DOM.getAttribute(self.getElement(), "value")
示例14: getName
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getAttribute [as 别名]
def getName(self):
return DOM.getAttribute(self.getElement(), "name")
示例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")