本文整理汇总了Python中IAccessibleHandler类的典型用法代码示例。如果您正苦于以下问题:Python IAccessibleHandler类的具体用法?Python IAccessibleHandler怎么用?Python IAccessibleHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IAccessibleHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Notify
def Notify(self):
try:
JABHandler.pumpAll()
IAccessibleHandler.pumpAll()
queueHandler.pumpAll()
mouseHandler.pumpAll()
except:
log.exception("errors in this core pump cycle")
baseObject.AutoPropertyObject.invalidateCaches()
watchdog.alive()
示例2: processPendingEvents
def processPendingEvents(processEventQueue=True):
# Import late to avoid circular import.
import IAccessibleHandler
import JABHandler
import wx
import queueHandler
watchdog.alive()
wx.Yield()
JABHandler.pumpAll()
IAccessibleHandler.pumpAll()
import baseObject
baseObject.AutoPropertyObject.invalidateCaches()
if processEventQueue:
queueHandler.flushQueue(queueHandler.eventQueue)
示例3: _get_firstChild
def _get_firstChild(self):
# accNavigate incorrectly returns nothing for NAVDIR_FIRSTCHILD and requesting one child with AccessibleChildren causes a crash.
# Therefore, we must use accChild(1).
child = IAccessibleHandler.accChild(self.IAccessibleObject, 1)
if not child:
return None
return IAccessible(IAccessibleObject=child[0], IAccessibleChildID=child[1])
示例4: locateHTMLElementByID
def locateHTMLElementByID(document,ID):
try:
element=document.getElementsByName(ID).item(0)
except COMError as e:
log.debugWarning("document.getElementsByName failed with COMError %s"%e)
element=None
if element:
return element
try:
nodeName=document.body.nodeName
except COMError as e:
log.debugWarning("document.body.nodeName failed with COMError %s"%e)
return None
if nodeName=="FRAMESET":
tag="frame"
else:
tag="iframe"
try:
frames=document.getElementsByTagName(tag)
except COMError as e:
log.debugWarning("document.getElementsByTagName failed with COMError %s"%e)
return None
for frame in frames:
pacc=IAccessibleFromHTMLNode(frame)
res=IAccessibleHandler.accChild(pacc,1)
if not res: continue
childElement=HTMLNodeFromIAccessible(res[0])
if not childElement: continue
childElement=locateHTMLElementByID(childElement.document,ID)
if not childElement: continue
return childElement
示例5: _get_parent
def _get_parent(self):
#Special code to support Mozilla node_child_of relation (for comboboxes)
res=IAccessibleHandler.accNavigate(self.IAccessibleObject,self.IAccessibleChildID,IAccessibleHandler.NAVRELATION_NODE_CHILD_OF)
if res and res!=(self.IAccessibleObject,self.IAccessibleChildID):
newObj=IAccessible(IAccessibleObject=res[0],IAccessibleChildID=res[1])
if newObj:
return newObj
return super(Mozilla,self).parent
示例6: _get_parent
def _get_parent(self):
acc = IAccessibleHandler.accParent(self.IAccessibleObject, 0)
if not acc:
return super(IAccessible,self).parent
# HACK: WindowFromAccessibleObject fails on some WebKit objects retrieved using accParent.
# The window handle is the same for all nodes in a document anyway.
# Note that WindowFromAccessibleObject seems to work for children and siblings,
# so we don't need to do this for those.
return IAccessible(IAccessibleObject=acc[0], IAccessibleChildID=0, windowHandle=self.windowHandle)
示例7: getChildHTMLNodeFromFrame
def getChildHTMLNodeFromFrame(frame):
try:
pacc=IAccessibleFromHTMLNode(frame)
except NotImplementedError:
# #1569: It's not possible to get an IAccessible from frames marked with an ARIA role of presentation.
# In this case, just skip this frame.
return
res=IAccessibleHandler.accChild(pacc,1)
if not res: return
return HTMLNodeFromIAccessible(res[0])
示例8: run
def run(self):
global _isPumpPending
_isPumpPending = False
watchdog.alive()
try:
if touchHandler.handler:
touchHandler.handler.pump()
JABHandler.pumpAll()
IAccessibleHandler.pumpAll()
queueHandler.pumpAll()
mouseHandler.pumpAll()
braille.pumpAll()
except:
log.exception("errors in this core pump cycle")
baseObject.AutoPropertyObject.invalidateCaches()
watchdog.asleep()
if _isPumpPending and not _pump.IsRunning():
# #3803: Another pump was requested during this pump execution.
# As our pump is not re-entrant, schedule another pump.
_pump.Start(PUMP_MAX_DELAY, True)
示例9: event_NVDAObject_init
def event_NVDAObject_init(self,obj):
#The root document of HTML Metro Apps must be treeted as an application.
if isinstance(obj,Body) and obj.windowClassName=="Internet Explorer_Server":
try:
paccParent=obj.IAccessibleObject.accParent.accParent
identity=IAccessibleHandler.getIAccIdentity(paccParent,0)
except (COMError,AttributeError):
identity=None
if identity:
windowHandle=identity.get('windowHandle')
if windowHandle and winUser.getClassName(windowHandle)=="Web Platform Embedding":
obj.role=controlTypes.ROLE_APPLICATION
示例10: locateHTMLElementByID
def locateHTMLElementByID(document, ID):
try:
elements = document.getElementsByName(ID)
if elements is not None:
element = elements.item(0)
else: # probably IE 10 in standards mode (#3151)
try:
element = document.all.item(ID)
except:
element = None
except COMError as e:
log.debugWarning("document.getElementsByName failed with COMError %s" % e)
element = None
if element:
return element
try:
nodeName = document.body.nodeName
except COMError as e:
log.debugWarning("document.body.nodeName failed with COMError %s" % e)
return None
if nodeName:
nodeName = nodeName.upper()
if nodeName == "FRAMESET":
tag = "frame"
else:
tag = "iframe"
try:
frames = document.getElementsByTagName(tag)
except COMError as e:
log.debugWarning("document.getElementsByTagName failed with COMError %s" % e)
return None
if not frames: # frames can be None in IE 10
return None
for frame in frames:
try:
pacc = IAccessibleFromHTMLNode(frame)
except NotImplementedError:
# #1569: It's not possible to get an IAccessible from frames marked with an ARIA role of presentation.
# In this case, just skip this frame.
continue
res = IAccessibleHandler.accChild(pacc, 1)
if not res:
continue
childElement = HTMLNodeFromIAccessible(res[0])
if not childElement:
continue
childElement = locateHTMLElementByID(childElement.document, ID)
if not childElement:
continue
return childElement
示例11: _getPhysicalFocus
def _getPhysicalFocus(self):
try:
paccParent=self.IAccessibleObject.accParent
except COMError:
paccParent=None
if not paccParent:
return
try:
paccFocus=paccParent.accFocus
except COMError:
paccFocus=None
if not paccFocus:
return
return IAccessible(IAccessibleObject=IAccessibleHandler.normalizeIAccessible(paccFocus),IAccessibleChildID=0)
示例12: _get_parent
def _get_parent(self):
#Special code to support Mozilla node_child_of relation (for comboboxes)
res=IAccessibleHandler.accNavigate(self.IAccessibleObject,self.IAccessibleChildID,IAccessibleHandler.NAVRELATION_NODE_CHILD_OF)
if res and res!=(self.IAccessibleObject,self.IAccessibleChildID):
#Gecko can sometimes give back a broken application node with a windowHandle of 0
#The application node is annoying, even if it wasn't broken
#So only use the node_child_of object if it has a valid IAccessible2 windowHandle
try:
windowHandle=res[0].windowHandle
except (COMError,AttributeError):
windowHandle=None
if windowHandle:
newObj=IAccessible(windowHandle=windowHandle,IAccessibleObject=res[0],IAccessibleChildID=res[1])
if newObj:
return newObj
return super(Mozilla,self).parent
示例13: _get_parent
def _get_parent(self):
parent = super(GeckoPluginWindowRoot, self).parent
if parent.IAccessibleRole == oleacc.ROLE_SYSTEM_CLIENT:
# Skip the window wrapping the plugin window,
# which doesn't expose a Gecko accessible in Gecko >= 11.
parent = parent.parent.parent
ver = getGeckoVersion(parent)
if ver and ver.major != 1:
res = IAccessibleHandler.accNavigate(parent.IAccessibleObject, 0, IAccessibleHandler.NAVRELATION_EMBEDS)
if res:
obj = IAccessible(IAccessibleObject=res[0], IAccessibleChildID=res[1])
if obj:
if controlTypes.STATE_OFFSCREEN not in obj.states:
return obj
else:
log.debugWarning("NAVRELATION_EMBEDS returned an offscreen document, name %r" % obj.name)
else:
log.debugWarning("NAVRELATION_EMBEDS returned an invalid object")
else:
log.debugWarning("NAVRELATION_EMBEDS failed")
return parent
示例14: getNVDAObjectFromIdentifier
def getNVDAObjectFromIdentifier(self, docHandle, ID):
try:
pacc=self.rootNVDAObject.IAccessibleObject.accChild(ID)
except COMError:
return None
return NVDAObjects.IAccessible.IAccessible(windowHandle=docHandle,IAccessibleObject=IAccessibleHandler.normalizeIAccessible(pacc),IAccessibleChildID=0)
示例15: _getFormatFieldAndOffsets
def _getFormatFieldAndOffsets(self,offset,formatConfig,calculateOffsets=True):
obj = self.obj
try:
startOffset,endOffset,attribsString=obj.IAccessibleTextObject.attributes(offset)
except COMError:
log.debugWarning("could not get attributes",exc_info=True)
return textInfos.FormatField(),(self._startOffset,self._endOffset)
formatField=textInfos.FormatField()
if not attribsString and offset>0:
try:
attribsString=obj.IAccessibleTextObject.attributes(offset-1)[2]
except COMError:
pass
if attribsString:
formatField.update(IAccessibleHandler.splitIA2Attribs(attribsString))
try:
escapement = int(formatField["CharEscapement"])
if escapement < 0:
textPos = "sub"
elif escapement > 0:
textPos = "super"
else:
textPos = "baseline"
formatField["text-position"] = textPos
except KeyError:
pass
try:
formatField["font-name"] = formatField["CharFontName"]
except KeyError:
pass
try:
formatField["font-size"] = "%spt" % formatField["CharHeight"]
except KeyError:
pass
try:
formatField["italic"] = formatField["CharPosture"] == "2"
except KeyError:
pass
try:
formatField["strikethrough"] = formatField["CharStrikeout"] == "1"
except KeyError:
pass
try:
underline = formatField["CharUnderline"]
if underline == "10":
# Symphony doesn't provide for semantic communication of spelling errors, so we have to rely on the WAVE underline type.
formatField["invalid-spelling"] = True
else:
formatField["underline"] = underline != "0"
except KeyError:
pass
try:
formatField["bold"] = float(formatField["CharWeight"]) > 100
except KeyError:
pass
try:
color=formatField.pop('CharColor')
except KeyError:
color=None
if color:
formatField['color']=colors.RGB.fromString(color)
try:
backgroundColor=formatField.pop('CharBackColor')
except KeyError:
backgroundColor=None
if backgroundColor:
formatField['background-color']=colors.RGB.fromString(backgroundColor)
# optimisation: Assume a hyperlink occupies a full attribute run.
try:
if obj.IAccessibleTextObject.QueryInterface(IAccessibleHandler.IAccessibleHypertext).hyperlinkIndex(offset) != -1:
formatField["link"] = True
except COMError:
pass
if offset == 0:
# Only include the list item prefix on the first line of the paragraph.
numbering = formatField.get("Numbering")
if numbering:
formatField["line-prefix"] = numbering.get("NumberingPrefix") or numbering.get("BulletChar")
if obj.hasFocus:
# Symphony exposes some information for the caret position as attributes on the document object.
# optimisation: Use the tree interceptor to get the document.
try:
docAttribs = obj.treeInterceptor.rootNVDAObject.IA2Attributes
except AttributeError:
# No tree interceptor, so we can't efficiently fetch this info.
pass
else:
try:
formatField["page-number"] = docAttribs["page-number"]
except KeyError:
pass
try:
formatField["line-number"] = docAttribs["line-number"]
except KeyError:
pass
#.........这里部分代码省略.........