本文整理汇总了Python中pyjamas.ui.Hyperlink.Hyperlink.getElement方法的典型用法代码示例。如果您正苦于以下问题:Python Hyperlink.getElement方法的具体用法?Python Hyperlink.getElement怎么用?Python Hyperlink.getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.ui.Hyperlink.Hyperlink
的用法示例。
在下文中一共展示了Hyperlink.getElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: replaceLinks
# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import getElement [as 别名]
def replaceLinks(self, tagname="a", use_page_href=True, ajaxify=False):
""" replaces <tag href="#pagename">sometext</tag> with:
Hyperlink("sometext", "pagename"). Hyperlinks use
the History module so the notification will come
in on an onHistoryChanged.
"""
self._clear_hyperlinks()
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 use_page_href and not l[0].startswith(pagehref):
continue
token = l[1]
if not token:
continue
html = DOM.getInnerHTML(el)
parent = DOM.getParent(el)
index = DOM.getChildIndex(parent, el)
if ajaxify:
token = '!%s' % token
hl = Hyperlink(TargetHistoryToken=token,
HTML=html,
Element=DOM.createSpan())
DOM.insertChild(parent, hl.getElement(), index)
parent.removeChild(el)
self.children.insert(index, hl)
hl.setParent(self)
self.hyperlinks.append(hl)
示例2: replaceLinks
# 需要导入模块: from pyjamas.ui.Hyperlink import Hyperlink [as 别名]
# 或者: from pyjamas.ui.Hyperlink.Hyperlink import getElement [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)