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


Python DOM.getChildCount方法代码示例

本文整理汇总了Python中pyjamas.DOM.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.getChildCount方法的具体用法?Python DOM.getChildCount怎么用?Python DOM.getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.DOM的用法示例。


在下文中一共展示了DOM.getChildCount方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: findTextPoint

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
def findTextPoint(node, offset):
    """
    If the found range is not on a text node, this finds the cooresponding
    text node to where the selection is.  If it is on a text node, just
    directly creates the endpoint from it.

    @param node node returned as an endpoint of a range
    @param offset offset returned to the endpoint of a range
    @return A range end point with a proper (or None) text node
    """
    if DOM.getNodeType(node) == DOM.TEXT_NODE:
        res = RangeEndPoint(node, offset)
    else:
        # search backwards unless this is after the last node
        dirn = offset >= DOM.getChildCount(node)
        child = (DOM.getChildCount(node) == 0) and node or DOM.getChild(node, dirn and (offset - 1) or offset)
        # Get the previous/next text node
        text = RangeUtil.getAdjacentTextElement(child, dirn)
        if text is None:
            # If we didn't find a text node in the preferred direction,
            # try the other direction
            dirn = not dirn
            text = RangeUtil.getAdjacentTextElement(child, dirn)

        res = RangeEndPoint(text, dirn)

    return res
开发者ID:luiseduardohdbackup,项目名称:pyjs,代码行数:29,代码来源:Range.py

示例2: _checkVerticalContainer

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def _checkVerticalContainer(self):
     """ use this to delay effect of self.vertical being set.
         self.setVertical can now be used, rather than self.vertical
         force-set in constructor
     """
     if DOM.getChildCount(self.body) == 0:
         DOM.appendChild(self.body, DOM.createTR())
开发者ID:anandology,项目名称:pyjamas,代码行数:9,代码来源:MenuBar.py

示例3: clear

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def clear(self):
     # as long as the canvas has children other than our <defs> element
     while DOM.getChildCount(self.canvas) > 1:
         # remove the second one (skip defs)
         DOM.removeChild(self.canvas, DOM.getChild(self.canvas, 1))
     # # init styles context stack
     # self.ctx_stack = []
     # # init current context
     # self._init_context()
     # also reset path
     self.beginPath()
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:13,代码来源:SVGCanvas.py

示例4: getTargetInChildren

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
def getTargetInChildren(element, x, y):
    """
    x and y are absolute coordinates within the document.
    Return the last child of element that contains (x,y).
    Return None if not found.
    """
    return_elt = None
    if DOM.getChildCount(element) > 0:
        for elt in DOM.IterWalkChildren(element):
            hit = isIn(elt, x, y)
            if hit:
                return_elt = elt
    return return_elt
开发者ID:Afey,项目名称:pyjs,代码行数:15,代码来源:utils.py

示例5: getAdjacentTextElement

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
def getAdjacentTextElement(current, topMostNode, forward=None, traversingUp=False):
    if forward is None:
        forward = topMostNode
        topMostNode = None

    res = None

    #print "getAdjacentTextElement", current, topMostNode, forward, traversingUp

    # If traversingUp, then the children have already been processed
    if not traversingUp:
        if DOM.getChildCount(current) > 0:
            if forward:
                node = DOM.getFirstChild(current)
            else:
                node = DOM.getLastChild(current)

            if DOM.getNodeType(node) == DOM.TEXT_NODE:
                res = node
            else:
                # Depth first traversal, the recursive call deals with
                # siblings
                res = getAdjacentTextElement(node, topMostNode,
                                        forward, False)

    if res is None:
        if forward:
            node = current.nextSibling
        else:
            node = current.previousSibling
        # Traverse siblings
        if node is not None:
            if DOM.getNodeType(node) == DOM.TEXT_NODE:
                res = node
            else:
                #print node, DOM.getNodeType(node), node.innerHTML
                # Depth first traversal, the recursive call deals with
                # siblings
                res = getAdjacentTextElement(node, topMostNode,
                                        forward, False)

    # Go up and over if still not found
    if (res is None)  and  (not DOM.compare(current, topMostNode)):
        node = current.parentNode
        # Stop at document (technically could stop at "html" tag)
        if (node is not None)  and  \
                (DOM.getNodeType(node) != DOM.DOCUMENT_NODE):
            res = getAdjacentTextElement(node, topMostNode,
                                        forward, True)
    return res
开发者ID:Afey,项目名称:pyjs,代码行数:52,代码来源:RangeUtil.py

示例6: __init__

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def __init__(self, defs_elem, elem_type, width, height):
     # save defs
     self.defs_elem = defs_elem
     # save dimensions of canvas as floats
     self.canvas_width = float(width)
     self.canvas_height = float(height)
     # create the gradient element
     self.elem = self._createElementSVG(elem_type)
     # make a unique id
     self.id = "grad"+str(DOM.getChildCount(defs_elem) + 1)
     # set the element's id
     DOM.setElemAttribute(self.elem, "id", self.id)
     # set for canvas-based coordinates
     DOM.setElemAttribute(self.elem, "gradientUnits", "userSpaceOnUse")
     # add the new element to defs
     DOM.appendChild(defs_elem, self.elem)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:18,代码来源:SVGCanvas.py

示例7: _apply_current_transforms

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
    def _apply_current_transforms(self):
        # if the current transform group already has elements
        if DOM.getChildCount(self.ctx["transform_group"]) > 0:
            # we create a new one
            group = self._createElementSVG("g")
            # add a new transform group to the canvas
            DOM.appendChild(self.canvas, group)
            # and make it the current tranform group
            self.ctx["transform_group"] = group
        # build the transform spec
        # just to make the next line shorter
        mx = self.ctx["matrix"]
        transform = "matrix("+str(mx[0])+","+str(mx[1])+","+str(mx[2])+","+str(mx[3])+","+str(mx[4])+","+str(mx[5])+") "
        # we need to update the transform attribute of the current group
#        print "Apply transform:",transform
        DOM.setElemAttribute(self.ctx["transform_group"], "transform", transform)
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:18,代码来源:SVGCanvas.py

示例8: clear

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def clear(self):
     """
     Clears the entire canvas.
     Also deletes the context stack and current path
     TODO: NEED TO RESET STYLES?
     TODO: NEED TO RESET STYLES?
     """
     # as long as the canvas has children other than our <defs> element
     while DOM.getChildCount(self.canvas) > 1:
         # remove the second one (skip defs)
         DOM.removeChild(self.canvas, DOM.getChild(self.canvas, 1))
     # # init styles context stack
     # self.ctx_stack = []
     # # init current context
     # self._init_context()
     # also reset path
     self.beginPath()
开发者ID:Afey,项目名称:pyjs,代码行数:19,代码来源:SVGCanvas.py

示例9: realizeTable

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
    def realizeTable(self, beingAdded):
        bodyElement = self.getBody()

        while DOM.getChildCount(bodyElement) > 0:
            DOM.removeChild(bodyElement, DOM.getChild(bodyElement, 0))

        rowCount = 1
        colCount = 1
        for child in self.dock_children:
            dir = child.getLayoutData().direction
            if dir == self.NORTH or dir == self.SOUTH:
                rowCount += 1
            elif dir == self.EAST or dir == self.WEST:
                colCount += 1

        rows = []
        for i in range(rowCount):
            rows.append(DockPanelTmpRow())
            rows[i].tr = DOM.createTR()
            DOM.appendChild(bodyElement, rows[i].tr)

        westCol = 0
        eastCol = colCount - 1
        northRow = 0
        southRow = rowCount - 1
        centerTd = None

        for child in self.dock_children:
            layout = child.getLayoutData()

            td = DOM.createTD()
            layout.td = td
            DOM.setAttribute(layout.td, "align", layout.hAlign)
            DOM.setStyleAttribute(layout.td, "verticalAlign", layout.vAlign)
            DOM.setAttribute(layout.td, "width", layout.width)
            DOM.setAttribute(layout.td, "height", layout.height)

            if layout.direction == self.NORTH:
                DOM.insertChild(rows[northRow].tr, td, rows[northRow].center)
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "colSpan", eastCol - westCol + 1)
                northRow += 1
            elif layout.direction == self.SOUTH:
                DOM.insertChild(rows[southRow].tr, td, rows[southRow].center)
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "colSpan", eastCol - westCol + 1)
                southRow -= 1
            elif layout.direction == self.WEST:
                row = rows[northRow]
                DOM.insertChild(row.tr, td, row.center)
                row.center += 1
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "rowSpan", southRow - northRow + 1)
                westCol += 1
            elif layout.direction == self.EAST:
                row = rows[northRow]
                DOM.insertChild(row.tr, td, row.center)
                self.appendAndMaybeAdopt(td, child.getElement(), beingAdded)
                DOM.setIntAttribute(td, "rowSpan", southRow - northRow + 1)
                eastCol -= 1
            elif layout.direction == self.CENTER:
                centerTd = td

        if self.center is not None:
            row = rows[northRow]
            DOM.insertChild(row.tr, centerTd, row.center)
            self.appendAndMaybeAdopt(centerTd, self.center.getElement(), beingAdded)
开发者ID:andreyvit,项目名称:pyjamas,代码行数:69,代码来源:DockPanel.py

示例10: getItemCount

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def getItemCount(self):
     return DOM.getChildCount(self.getElement())
开发者ID:Afey,项目名称:pyjs,代码行数:4,代码来源:ListBox.py

示例11: clear

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def clear(self):
     h = self.getElement()
     while DOM.getChildCount(h) > 0:
         DOM.removeChild(h, DOM.getChild(h, 0))
开发者ID:Afey,项目名称:pyjs,代码行数:6,代码来源:ListBox.py

示例12: checkIndex

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def checkIndex(self, index):
     elem = self.getElement()
     if (index < 0) or (index >= DOM.getChildCount(elem)):
         #throw new IndexOutOfBoundsException();
         pass
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:ListBox.py

示例13: clearItems

# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import getChildCount [as 别名]
 def clearItems(self):
     container = self.getItemContainerElement()
     while DOM.getChildCount(container) > 0:
         DOM.removeChild(container, DOM.getChild(container, 0))
     self.items = []
开发者ID:FreakTheMighty,项目名称:pyjamas,代码行数:7,代码来源:MenuBar.py


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