def get(app): assert not app.dead scroll_pane = app.child(roleName='scroll pane') scroll_pane.grabFocus() is_focused(scroll_pane) pred = predicate.IsADialogNamed(dialogName='Connection details') win = scroll_pane.findAncestor(pred) return win
def dialog(self, dialogName, recursive=False, showingOnly=None): """ Search below this node for a dialog with the given name, returning a Window instance. This is implemented using findChild, and hence will automatically retry if no such child is found, and will eventually raise an exception. It also logs the search. FIXME: should this method activate the dialog? """ return self.findChild(predicate.IsADialogNamed(dialogName=dialogName), recursive, showingOnly=showingOnly)
def getRelativeSearch(self): """ Get a (ancestorNode, predicate, isRecursive) triple that identifies the best way to find this Node uniquely. FIXME: or None if no such search exists? FIXME: may need to make this more robust FIXME: should this be private? """ if config.debugSearchPaths: logger.log("getRelativeSearchPath(%s)" % self) assert self assert self.parent isRecursive = False ancestor = self.parent # iterate up ancestors until you reach an identifiable one, # setting the search to be isRecursive if need be: while not self.__nodeIsIdentifiable(ancestor): ancestor = ancestor.parent isRecursive = True # Pick the most appropriate predicate for finding this node: if self.labellee: if self.labellee.name: return (ancestor, predicate.IsLabelledAs(self.labellee.name), isRecursive) if self.roleName == 'menu': return (ancestor, predicate.IsAMenuNamed(self.name), isRecursive) elif self.roleName == 'menu item' or self.roleName == 'check menu item': return (ancestor, predicate.IsAMenuItemNamed(self.name), isRecursive) elif self.roleName == 'text': return (ancestor, predicate.IsATextEntryNamed(self.name), isRecursive) elif self.roleName == 'push button': return (ancestor, predicate.IsAButtonNamed(self.name), isRecursive) elif self.roleName == 'frame': return (ancestor, predicate.IsAWindowNamed(self.name), isRecursive) elif self.roleName == 'dialog': return (ancestor, predicate.IsADialogNamed(self.name), isRecursive) else: pred = predicate.GenericPredicate( name=self.name, roleName=self.roleName) return (ancestor, pred, isRecursive)
def __call__(self, name): """ Search for a dialog that matches the given name and refocus on it. """ result = None pred = predicate.IsADialogNamed(name) try: result = FocusApplication.node.findChild(pred, requireResult=False, recursive=False) except AttributeError: pass if result: FocusDialog.node = result FocusWidget.node = None else: if config.fatalErrors: raise FocusError(pred.debugName) else: focusFailed(pred) return False return True