本文整理汇总了Python中pyatspi.findDescendant函数的典型用法代码示例。如果您正苦于以下问题:Python findDescendant函数的具体用法?Python findDescendant怎么用?Python findDescendant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了findDescendant函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onWindowActivated
def onWindowActivated(self, event):
"""Called whenever one of gcalctool's toplevel windows is activated.
Arguments:
- event: the window activated Event
"""
if self._resultsDisplay and self._statusLine:
gtk.Script.onWindowActivated(self, event)
return
obj = event.source
role = obj.getRole()
if role != pyatspi.ROLE_FRAME:
gtk.Script.onWindowActivated(self, event)
return
isEditbar = lambda x: x and x.getRole() == pyatspi.ROLE_EDITBAR
self._resultsDisplay = pyatspi.findDescendant(obj, isEditbar)
if not self._resultsDisplay:
self.presentMessage(messages.CALCULATOR_DISPLAY_NOT_FOUND)
isStatusLine = lambda x: x and x.getRole() == pyatspi.ROLE_TEXT \
and not x.getState().contains(pyatspi.STATE_EDITABLE)
self._statusLine = pyatspi.findDescendant(obj, isStatusLine)
gtk.Script.onWindowActivated(self, event)
示例2: doesrowexist
def doesrowexist(self, window_name, object_name, row_text):
'''
Verify table cell value with given text
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type object_name: string
@param row_text: Row text to match
@type string
@return: 1 on success 0 on failure.
@rtype: integer
'''
obj = self._get_object(window_name, object_name)
def _searchString(acc):
try:
itext = acc.queryText()
except NotImplementedError:
return False
return row_text == itext.getText(0,-1)
results = pyatspi.findDescendant(obj, _searchString)
return int(bool(results))
示例3: setup
def setup(self, test):
self._registry = pyatspi.Registry()
print self._path
self._desktop = self._registry.getDesktop(0)
self._root = pyatspi.findDescendant(
self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_WINDOW
)
示例4: _isCandidateWindow
def _isCandidateWindow(self, window):
if self._script.utilities.isDead(window):
msg = "SOFFICE: %s is not candidate window because it's dead." % window
debug.println(debug.LEVEL_INFO, msg, True)
return False
if window and window.childCount and window.getRole() == pyatspi.ROLE_FRAME:
child = self._findChildDialog(window[0])
if child and child.getRole() == pyatspi.ROLE_DIALOG:
isPageTabList = lambda x: x and x.getRole() == pyatspi.ROLE_PAGE_TAB_LIST
if pyatspi.findDescendant(child, isPageTabList):
return False
isComboBox = lambda x: x and x.getRole() == pyatspi.ROLE_COMBO_BOX
return pyatspi.findDescendant(child, isComboBox)
return False
示例5: findMessageBodyChild
def findMessageBodyChild(self, root):
roles = [pyatspi.ROLE_DOCUMENT_FRAME, pyatspi.ROLE_DOCUMENT_WEB]
isDocument = lambda x: x and x.getRole() in roles
candidate = pyatspi.findDescendant(root, isDocument)
if self.isEmbeddedDocument(candidate):
return self.findMessageBodyChild(candidate)
return candidate
示例6: _isCandidateWindow
def _isCandidateWindow(self, window):
if window and window.childCount and window.getRole() == pyatspi.ROLE_FRAME:
child = window[0]
if child.getRole() == pyatspi.ROLE_DIALOG:
isPageTabList = lambda x: x and x.getRole() == pyatspi.ROLE_PAGE_TAB_LIST
if not pyatspi.findDescendant(child, isPageTabList):
return True
return False
示例7: _findErrorWidget
def _findErrorWidget(self, root):
isPanel = lambda x: x and x.getRole() == pyatspi.ROLE_PANEL
panel = pyatspi.findAncestor(self._changeToEntry, isPanel)
if not panel:
return None
isError = lambda x: x and x.getRole() == pyatspi.ROLE_LABEL \
and not ":" in x.name and not x.getRelationSet()
return pyatspi.findDescendant(panel, isError)
示例8: searchObj
def searchObj(self, appname, ctrlname, elementname):
reg = pyatspi.Registry
desktop = reg.getDesktop(0)
app = pyatspi.findDescendant(desktop, lambda x: x.name == self.appname)
self.appname = app
if self.ctrlname != None and self.ctrlname.startswith("application"):
searchings = []
for i in desktop:
if i is not None:
searchings.append(i)
elif self.ctrlname == None:
searchings = pyatspi.findAllDescendants(self.appname, lambda x: x.name == self.elementname)
elif self.ctrlname == None and self.findtype == "find":
searchings = pyatspi.findDescendant(self.appname, lambda x: x.name == self.elementname)
else:
searchings = self.findFunc()
return searchings
示例9: setup
def setup(self, test):
self._registry = pyatspi.Registry()
import time
self._desktop = self._registry.getDesktop(0)
print "--desktop len", len(self._desktop)
for i in self._desktop:
try:
print "-- object",i,i.getRole()
except:
pass
self._root = pyatspi.findDescendant (self._desktop, lambda x: x.name == "atspi-test-main" and x.getRole() == pyatspi.ROLE_APPLICATION)
print "--root", self._root
示例10: findFunc
def findFunc(self):
if self.findtype == 'find':
try:
searchings = [pyatspi.findDescendant(self.appname, lambda x: x.getRoleName() == self.ctrlname)]
except TypeError:
searchings = []
elif self.findtype == 'findAll':
try:
searchings = pyatspi.findAllDescendants(self.appname, lambda x: x.getRoleName() == self.ctrlname)
except TypeError:
searchings = []
return searchings
示例11: _find_root_doc
def _find_root_doc(self, window_acc):
agent_id = self._get_agent()
pred = lambda x: False
if agent_id == self.AGENT_MOZILLA or agent_id ==self.AGENT_CHROME:
# Firefox
def pred(x):
p = x.parent
if p.getRole() == pyatspi.ROLE_INTERNAL_FRAME:
attribs = \
dict([a.split(':',1) for a in p.getAttributes()])
if 'browser' in attribs.get('tag', '') and \
p.getState().contains(pyatspi.STATE_SHOWING):
return True
return False
return pyatspi.findDescendant(window_acc, pred)
示例12: _generateChildWidget
def _generateChildWidget(self, obj, **args):
widgetRoles = [pyatspi.ROLE_CHECK_BOX,
pyatspi.ROLE_COMBO_BOX,
pyatspi.ROLE_PUSH_BUTTON,
pyatspi.ROLE_RADIO_BUTTON,
pyatspi.ROLE_SLIDER,
pyatspi.ROLE_TOGGLE_BUTTON]
isWidget = lambda x: x and x.getRole() in widgetRoles
# For GtkListBox, such as those found in the control center
if obj.parent and obj.parent.getRole() == pyatspi.ROLE_LIST_BOX:
widget = pyatspi.findDescendant(obj, isWidget)
if widget:
return self.generate(widget, includeContext=False)
return []
示例13: onFocusedChanged
def onFocusedChanged(self, event):
"""Callback for object:state-changed:focused accessibility events."""
if not event.detail1:
return
obj = event.source
try:
role = obj.getRole()
name = obj.name
except:
return
# The dialog will get presented when its first child gets focus.
if role == pyatspi.ROLE_DIALOG:
return
# We're getting a spurious focus claim from the gnome-shell window after
# the window switcher is used.
if role == pyatspi.ROLE_WINDOW:
return
if role == pyatspi.ROLE_MENU_ITEM and not name \
and not self.utilities.labelsForObject(obj):
isRealFocus = lambda x: x and x.getRole() == pyatspi.ROLE_SLIDER
descendant = pyatspi.findDescendant(obj, isRealFocus)
if descendant:
orca.setLocusOfFocus(event, descendant)
return
# This is to present dialog boxes which are, to the user, newly
# activated. And if something is claiming to be focused that is
# not in a dialog, that's good to know as well, so update our
# state regardless.
activeDialog, timestamp = self._activeDialog
if not activeDialog:
isDialog = lambda x: x and x.getRole() == pyatspi.ROLE_DIALOG
dialog = pyatspi.utils.findAncestor(obj, isDialog)
self._activeDialog = (dialog, time.time())
if dialog:
orca.setLocusOfFocus(None, dialog)
labels = self.utilities.unrelatedLabels(dialog)
for label in labels:
self._activeDialogLabels[hash(label)] = label.name
clutter.Script.onFocusedChanged(self, event)
示例14: updateToPath
def updateToPath(self, app_name, path):
"""
Update the node with a new accessible by providing a tree path
in an application.
@param app_name: Application name.
@type app_name: string
@param path: The accessible path in the application.
@type path: list of integer
"""
acc = pyatspi.findDescendant(self.desktop, lambda x: x.name.lower() == app_name.lower(), breadth_first=True)
if acc is None:
return
while path:
child_index = path.pop(0)
try:
acc = acc[child_index]
except IndexError:
return
self.update(acc)
示例15: isComboBoxWithToggleDescendant
def isComboBoxWithToggleDescendant(self, obj):
if not (obj and obj.getRole() == pyatspi.ROLE_COMBO_BOX):
return False
rv = self._isComboBoxWithToggleDescendant.get(hash(obj))
if rv is not None:
return rv
isToggle = lambda x: x and x.getRole() == pyatspi.ROLE_TOGGLE_BUTTON
for child in obj:
if child.getRole() != pyatspi.ROLE_FILLER:
continue
toggle = pyatspi.findDescendant(child, isToggle)
rv = toggle is not None
if toggle:
self._isToggleDescendantOfComboBox[hash(toggle)] = True
break
self._isComboBoxWithToggleDescendant[hash(obj)] = rv
return rv