本文整理汇总了Python中pyjamas.DOM.getParent方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getParent方法的具体用法?Python DOM.getParent怎么用?Python DOM.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.getParent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setSelectionStyle
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def setSelectionStyle(self, item, selected):
if item is not None:
if selected:
item.addStyleName("gwt-TabBarItem-selected")
self.setStyleName(DOM.getParent(item.getElement()),
"gwt-TabBarItem-wrapper-selected", True)
else:
item.removeStyleName("gwt-TabBarItem-selected")
self.setStyleName(DOM.getParent(item.getElement()),
"gwt-TabBarItem-wrapper-selected", False)
示例2: remove
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def remove(self, widget):
if isinstance(widget, int):
widget = self.getWidget(widget)
if widget.getParent() != self:
return False
td = DOM.getParent(widget.getElement())
tr = DOM.getParent(td)
DOM.removeChild(self.getBody(), tr)
CellPanel.remove(self, widget)
return True
示例3: getEventTargetCell
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [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
示例4: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [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)
示例5: setCaption
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def setCaption(self, caption):
self.caption = caption
if caption is not None and not caption == "":
DOM.setInnerHTML(self.legend, caption)
DOM.insertChild(self.getElement(), self.legend, 0)
elif DOM.getParent(self.legend) is not None:
DOM.removeChild(self.getElement(), self.legend)
示例6: replaceLinks
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [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)
示例7: insertChildBefore
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [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)
示例8: disown
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def disown(self, widget):
if widget.getParent() != self:
console.error("widget %o is not a child of this panel %o", widget, self)
else:
element = widget.getElement()
widget.setParent(None)
parentElement = DOM.getParent(element)
if parentElement:
DOM.removeChild(parentElement, element)
示例9: getDividerIndex
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def getDividerIndex(self, elem):
while (elem is not None) and not DOM.compare(elem, self.getElement()):
expando = self._getIndex(elem)
if expando is not None:
return int(expando)
elem = DOM.getParent(elem)
return -1
示例10: disown
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def disown(self, widget):
if widget.getParent() is not self:
raise Exception("widget %s is not a child of this panel %s" % \
(str(widget), str(self)))
element = widget.getElement()
widget.setParent(None)
parentElement = DOM.getParent(element)
if parentElement is not None:
DOM.removeChild(parentElement, element)
示例11: getTabHTML
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def getTabHTML(self, index):
widget = self.getTabWidget(index)
if hasattr(widget, "getHTML"):
return widget.getHTML()
elif hasattr(widget, "getText"): # assume it's a Label if it has getText
return widget.getText()
else:
fpe = DOM.getParent(self.focusablePanel.getElement())
return DOM.getInnerHTML(fpe)
示例12: insertTabWidget
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def insertTabWidget(self, widget, beforeIndex):
delWidget = ClickDelegatePanel(self, widget, self, self)
delWidget.setStyleName(self.STYLENAME_DEFAULT)
focusablePanel = delWidget.getFocusablePanel()
self.panel.insert(delWidget, beforeIndex + 1)
self.setStyleName(DOM.getParent(delWidget.getElement()),
self.STYLENAME_DEFAULT + "-wrapper", True)
示例13: onBrowserEvent
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [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)
示例14: insertTabWidget
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def insertTabWidget(self, widget, beforeIndex):
delWidget = ClickDelegatePanel(self, widget, self, self)
delWidget.setStyleName(self.STYLENAME_DEFAULT)
focusablePanel = delWidget.getFocusablePanel()
self.panel.insert(delWidget, self.panel.getElement(), beforeIndex + 1)
parent = DOM.getParent(delWidget.getElement())
#DOM.setStyleAttribute(parent, "flow", "left")
#DOM.setStyleAttribute(parent, "display", "inline")
self.setStyleName(parent,
self.STYLENAME_DEFAULT + "-wrapper", True)
示例15: getTabHTML
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getParent [as 别名]
def getTabHTML(self, index):
if index >= self.getTabCount():
return None
delPanel = self.panel.getWidget(index + 1)
focusablePanel = delPanel.getFocusablePanel()
widget = focusablePanel.getWidget()
if hasattr(widget, "getHTML"):
return widget.getHTML()
elif hasattr(widget, "getText"): # assume it's a Label if it has getText
return widget.getText()
else:
fpe = DOM.getParent(self.focusablePanel.getElement())
return DOM.getInnerHTML(fpe)