UI Proxy class that represents the UI element on target device. Any action performing on this instance is handled by Poco. It is not necessary to initialize this object manually. See ``QueryCondition`` for more details about how to select the UI elements. Args: poco: the p
| 75 | |
| 76 | |
| 77 | class UIObjectProxy(object): |
| 78 | """ |
| 79 | UI Proxy class that represents the UI element on target device. |
| 80 | |
| 81 | Any action performing on this instance is handled by Poco. It is not necessary to initialize this object manually. |
| 82 | See ``QueryCondition`` for more details about how to select the UI elements. |
| 83 | |
| 84 | Args: |
| 85 | poco: the poco instance |
| 86 | name: query condition of "name" attribute, i.e. the UI element(s) with ``name`` name will be selected |
| 87 | attrs: other query expressions except for the ``name`` |
| 88 | |
| 89 | See Also: |
| 90 | :py:meth:`select UI element(s) by poco <poco.pocofw.Poco.__call__>` |
| 91 | """ |
| 92 | |
| 93 | def __init__(self, poco, name=None, **attrs): |
| 94 | # query object in tuple |
| 95 | self.query = build_query(name, **attrs) |
| 96 | self.poco = poco |
| 97 | |
| 98 | # this flag is introduced to improve the performance, it is set if multiple UI elements are selected and |
| 99 | # it does not affect the selection result |
| 100 | # 上一次选择是否是多选,如果不是多选但需要访问所有UI elements时会进行重新选择。 |
| 101 | self._query_multiple = False |
| 102 | |
| 103 | # true or false whether the corresponding UI elements of this UI proxy (self) have been selected |
| 104 | # 此UI proxy是否已经查找到对应的UI elements了 |
| 105 | self._evaluated = False |
| 106 | |
| 107 | # the proxy object of UI elements, migh be `node` or `[nodes]`, the proxy type is specified by |
| 108 | # `self._nodes_proxy_is_list` |
| 109 | # 可能是远程node代理,也可能是远程[node]代理, 由`self._nodes_proxy_is_list`指定是何种proxy类型 |
| 110 | self._nodes = None |
| 111 | self._nodes_proxy_is_list = True |
| 112 | |
| 113 | # use only for caching some proxies of sorted nodes in `self.__getitem__` |
| 114 | # 仅用于__getitem__时保存好已排序的child代理对象 |
| 115 | self._sorted_children = None |
| 116 | |
| 117 | # focus point of the UI element, see `CoordinateSystem` for more details |
| 118 | # 相对于包围盒的focus point定义,用于touch/swipe/drag操作的局部相对定位 |
| 119 | self._focus = None |
| 120 | |
| 121 | def child(self, name=None, **attrs): |
| 122 | """ |
| 123 | Select the direct child(ren) from the UI element(s) given by the query expression, see ``QueryCondition`` for |
| 124 | more details about the selectors. |
| 125 | |
| 126 | Args: |
| 127 | name: query expression of attribute "name", i.e. the UI elements with ``name`` name will be selected |
| 128 | attrs: other query expression except for the ``name`` |
| 129 | |
| 130 | Returns: |
| 131 | :py:class:`UIObjectProxy <poco.proxy.UIObjectProxy>`: a new UI proxy object representing the child(ren) of |
| 132 | current UI element(s) |
| 133 | """ |
| 134 |