本文整理汇总了Python中pyjamas.DOM.getChildIndex方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getChildIndex方法的具体用法?Python DOM.getChildIndex怎么用?Python DOM.getChildIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.getChildIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildIndex [as 别名]
def onBrowserEvent(self, event):
if DOM.eventGetType(event) == "click":
td = self.getEventTargetCell(event)
if td is None:
return
tr = DOM.getParent(td)
body = DOM.getParent(tr)
row = DOM.getChildIndex(body, tr)
column = DOM.getChildIndex(tr, td)
for listener in self.tableListeners:
if hasattr(listener, 'onCellClicked'):
listener.onCellClicked(self, row, column)
else:
listener(self)
示例2: replaceLinks
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildIndex [as 别名]
def replaceLinks(self, tagname="a"):
""" replaces <tag href="#pagename">sometext</tag> with:
Hyperlink("sometext", "pagename")
"""
tags = self.findTags(tagname)
pageloc = Window.getLocation()
pagehref = pageloc.getPageHref()
for el in tags:
href = el.href
l = href.split("#")
if len(l) != 2:
continue
if l[0] != pagehref:
continue
token = l[1]
if not token:
continue
html = DOM.getInnerHTML(el)
parent = DOM.getParent(el)
index = DOM.getChildIndex(parent, el)
hl = Hyperlink(TargetHistoryToken=token,
HTML=html,
Element=DOM.createSpan())
DOM.insertChild(parent, hl.getElement(), index)
self.children.insert(index, hl)
parent.removeChild(el)
示例3: insertChildBefore
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildIndex [as 别名]
def insertChildBefore(new_elem, elem):
"""
Inserts an element "new_elem" before the element "elem".
"""
parent = DOM.getParent(elem)
id = DOM.getChildIndex(parent, elem)
DOM.insertChild(parent, new_elem, id)
示例4: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildIndex [as 别名]
def onBrowserEvent(self, event):
DOM.eventPreventDefault(event)
if not self.game.started:
return
td = self.getEventTargetCell(event)
if not td:
return
tr = DOM.getParent(td)
table = DOM.getParent(tr)
row = DOM.getChildIndex(table, tr)
column = DOM.getChildIndex(tr, td)
target_cell = self.getCell(row, column)
type = DOM.eventGetType(event)
event_mapper = {'click': 'onClick',
'contextmenu': 'onRightClick',
'mousedown': 'onMouseDown',
'mouseup': 'onMouseUp',
'mouseout': 'onMouseLeave'}
event_handler = event_mapper.get(type)
if event_handler:
getattr(self, event_handler)(target_cell)
示例5: _onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildIndex [as 别名]
def _onBrowserEvent(self, event, event_type):
td = self.getEventTargetCell(event)
if td is None:
return
tr = DOM.getParent(td)
body = DOM.getParent(tr)
row = DOM.getChildIndex(body, tr)
column = DOM.getChildIndex(tr, td)
if event_type == 'dblclick':
lists = self.dbltableListeners
else:
lists = self.tableListeners
for listener in lists:
if event_type == 'click' and \
hasattr(listener, 'onCellClicked'):
listener.onCellClicked(self, row, column)
elif event_type == 'dblclick' and \
hasattr(listener, 'onCellDoubleClicked'):
listener.onCellDoubleClicked(self, row, column)
else:
listener(self)
示例6: getPrevSibling
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildIndex [as 别名]
def getPrevSibling(elem):
parent = DOM.getParent(elem)
elem_index = DOM.getChildIndex(parent, elem)
children = list(DOM.iterChildren(parent))
return children[elem_index - 1]