当前位置: 首页>>代码示例>>Python>>正文


Python DOM.getChildIndex方法代码示例

本文整理汇总了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)
开发者ID:anandology,项目名称:pyjamas,代码行数:18,代码来源:HTMLTable.py

示例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)
开发者ID:Afey,项目名称:pyjs,代码行数:28,代码来源:HTMLLinkPanel.py

示例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)
开发者ID:certik,项目名称:sympy_gamma,代码行数:9,代码来源:nb.py

示例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)
开发者ID:anandology,项目名称:pyjamas,代码行数:24,代码来源:minesweeper.py

示例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)
开发者ID:Afey,项目名称:pyjs,代码行数:26,代码来源:HTMLTable.py

示例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]
开发者ID:certik,项目名称:sympy_gamma,代码行数:7,代码来源:nb.py


注:本文中的pyjamas.DOM.getChildIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。