Ejemplo n.º 1
0
    def __init__(self, poco, name=None, **attrs):
        # query object in tuple
        self.query = build_query(name, **attrs)
        self.poco = poco

        # this flag is introduced to improve the performance, it is set if multiple UI elements are selected and
        # it does not affect the selection result
        # 上一次选择是否是多选,如果不是多选但需要访问所有UI elements时会进行重新选择。
        self._query_multiple = False

        # true or false whether the corresponding UI elements of this UI proxy (self) have been selected
        # 此UI proxy是否已经查找到对应的UI elements了
        self._evaluated = False

        # the proxy object of UI elements, migh be `node` or `[nodes]`, the proxy type is specified by
        # `self._nodes_proxy_is_list`
        # 可能是远程node代理,也可能是远程[node]代理, 由`self._nodes_proxy_is_list`指定是何种proxy类型
        self._nodes = None
        self._nodes_proxy_is_list = True

        # use only for caching some proxies of sorted nodes in `self.__getitem__`
        # 仅用于__getitem__时保存好已排序的child代理对象
        self._sorted_children = None

        # focus point of the UI element, see `CoordinateSystem` for more details
        # 相对于包围盒的focus point定义,用于touch/swipe/drag操作的局部相对定位
        self._focus = None
Ejemplo n.º 2
0
    def parent(self):
        """
        Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for
        more details about the selectors.

        Warnings:
            Experimental method, may not be available for all drivers.

        Returns:
            :py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: a new UI proxy object representing the direct parent
            of the first UI element.
        """

        sub_query = build_query(None)  # as placeholder
        query = ('^', (self.query, sub_query))
        obj = UIObjectProxy(self.poco)
        obj.query = query
        return obj
Ejemplo n.º 3
0
    def sibling(self, name=None, **attrs):
        """
        Select the sibling(s) from the UI element(s) given by the query expression, see ``QueryCondition`` for more
        details about the selectors.

        Args:
            name: query expression of attribute "name", i.e. the UI elements with ``name`` name will be selected
            attrs: other query expression except for the ``name``

        Returns:
            :py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: a new UI proxy object representing the child(ren) of
            current UI element(s)
        """

        sub_query = build_query(name, **attrs)
        query = ('-', (self.query, sub_query))
        obj = UIObjectProxy(self.poco)
        obj.query = query
        return obj