コード例 #1
0
ファイル: device.py プロジェクト: mlyko/tadek-ui
 def _responseExpandAll(self, response):
     '''
     Expands an accessible tree item from the response recursively.
     '''
     path = response.accessible.path
     log.debug("Expanding accessible tree item recursively: %s" % path)
     if not response.status:
         return False
     accessible = response.accessible
     item = None
     if path.tuple:
         item = self._pathItem(path)
         if not item:
             log.warning("Invalid accessible tree path: %s" % path)
             return False
         # Update the item
         self._setAccessibleItem(accessible, item)
         item.setDisabled(False)
     else:
         self._treeWidget.clear()
     self._manualExpand = True
     if item:
         item.setExpanded(True)
     for child in accessible.children():
         self._accessibleItem(child, item or self._treeWidget,
                              recursive=True)
     for i in xrange(self._COLUMN_COUNT):
         self._treeWidget.resizeColumnToContents(i)
     self._manualExpand = False
     return True
コード例 #2
0
 def _responseExpandAll(self, response):
     '''
     Expands an accessible tree item from the response recursively.
     '''
     path = response.accessible.path
     log.debug("Expanding accessible tree item recursively: %s" % path)
     if not response.status:
         return False
     accessible = response.accessible
     item = None
     if path.tuple:
         item = self._pathItem(path)
         if not item:
             log.warning("Invalid accessible tree path: %s" % path)
             return False
         # Update the item
         self._setAccessibleItem(accessible, item)
         item.setDisabled(False)
     else:
         self._treeWidget.clear()
     self._manualExpand = True
     if item:
         item.setExpanded(True)
     for child in accessible.children():
         self._accessibleItem(child,
                              item or self._treeWidget,
                              recursive=True)
     for i in xrange(self._COLUMN_COUNT):
         self._treeWidget.resizeColumnToContents(i)
     self._manualExpand = False
     return True
コード例 #3
0
ファイル: explore.py プロジェクト: mlyko/tadek-tools
def _countColumnLens(accessible, lens):
    '''
    Counts length of each of column displaying a basic attibute of accessibles. 
    '''
    for i, attr in enumerate(_ATTRS_BASIC):
        item = getattr(accessible, attr[0])
        if not item:
            continue
        if not isinstance(item, basestring):
            item = str(item)
        lens[i] = max(len(item), lens[i])
    for child in accessible.children(force=False):
        _countColumnLens(child, lens)
コード例 #4
0
ファイル: explore.py プロジェクト: tadek-project/tadek-tools
def _countColumnLens(accessible, lens):
    '''
    Counts length of each of column displaying a basic attibute of accessibles. 
    '''
    for i, attr in enumerate(_ATTRS_BASIC):
        item = getattr(accessible, attr[0])
        if not item:
            continue
        if not isinstance(item, basestring):
            item = str(item)
        lens[i] = max(len(item), lens[i])
    for child in accessible.children(force=False):
        _countColumnLens(child, lens)
コード例 #5
0
ファイル: explore.py プロジェクト: mlyko/tadek-tools
def _printAccessibleAligned(accessible, lens):
    '''
    Aligns and prints the given accessible recursively.
    '''
    row = []
    for i, attr in enumerate(_ATTRS_BASIC):
        item = getattr(accessible, attr[0])
        if item is None:
            item = ''
        if not isinstance(item, basestring):
            item = str(item)
        row.append(utils.encode(item).ljust(lens[i]))
    print _COLUMN_SEPARATOR.join(row)
    for child in accessible.children(force=False):
        _printAccessibleAligned(child, lens)
コード例 #6
0
ファイル: explore.py プロジェクト: tadek-project/tadek-tools
def _printAccessibleAligned(accessible, lens):
    '''
    Aligns and prints the given accessible recursively.
    '''
    row = []
    for i, attr in enumerate(_ATTRS_BASIC):
        item = getattr(accessible, attr[0])
        if item is None:
            item = ''
        if not isinstance(item, basestring):
            item = str(item)
        row.append(utils.encode(item).ljust(lens[i]))
    print _COLUMN_SEPARATOR.join(row)
    for child in accessible.children(force=False):
        _printAccessibleAligned(child, lens)
コード例 #7
0
ファイル: device.py プロジェクト: mlyko/tadek-ui
 def _accessibleItem(self, accessible, parent, recursive=False):
     '''
     Adds an accessible tree item to the given parent.
     '''
     item = HighlightableItem(parent)
     self._setAccessibleItem(accessible, item)
     if accessible.count:
         if recursive:
             try:
                 item.setExpanded(True)
                 for child in accessible.children():
                     self._accessibleItem(child, item, True)
             except ValueError:
                 pass
         else:
             item.setChildIndicatorPolicy(HighlightableItem.ShowIndicator)
     return item
コード例 #8
0
 def _accessibleItem(self, accessible, parent, recursive=False):
     '''
     Adds an accessible tree item to the given parent.
     '''
     item = HighlightableItem(parent)
     self._setAccessibleItem(accessible, item)
     if accessible.count:
         if recursive:
             try:
                 item.setExpanded(True)
                 for child in accessible.children():
                     self._accessibleItem(child, item, True)
             except ValueError:
                 pass
         else:
             item.setChildIndicatorPolicy(HighlightableItem.ShowIndicator)
     return item