本文整理汇总了Python中speech.speakTextInfo函数的典型用法代码示例。如果您正苦于以下问题:Python speakTextInfo函数的具体用法?Python speakTextInfo怎么用?Python speakTextInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了speakTextInfo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _tableMovementScriptHelper
def _tableMovementScriptHelper(self, movement="next", axis=None):
if isScriptWaiting():
return
formatConfig=config.conf["documentFormatting"].copy()
formatConfig["reportTables"]=True
formatConfig["includeLayoutTables"]=True
try:
tableID, origRow, origCol, origRowSpan, origColSpan = self._getTableCellCoords(self.selection)
except LookupError:
# Translators: The message reported when a user attempts to use a table movement command
# when the cursor is not within a table.
ui.message(_("Not in a table cell"))
return
try:
info = self._getNearestTableCell(tableID, self.selection, origRow, origCol, origRowSpan, origColSpan, movement, axis)
except LookupError:
# Translators: The message reported when a user attempts to use a table movement command
# but the cursor can't be moved in that direction because it is at the edge of the table.
ui.message(_("Edge of table"))
# Retrieve the cell on which we started.
info = next(self._iterTableCells(tableID, row=origRow, column=origCol))
speech.speakTextInfo(info,formatConfig=formatConfig,reason=controlTypes.REASON_CARET)
info.collapse()
self.selection = info
示例2: script_caret_newLine
def script_caret_newLine(self,gesture):
try:
info=self.makeTextInfo(textInfos.POSITION_CARET)
except:
gesture.send()
return
bookmark=info.bookmark
gesture.send()
caretMoved,newInfo=self._hasCaretMoved(bookmark)
if not caretMoved or not newInfo:
return
# newInfo.copy should be good enough here, but in MS Word we get strange results.
try:
lineInfo=self.makeTextInfo(textInfos.POSITION_CARET)
except (RuntimeError,NotImplementedError):
return
lineInfo.expand(textInfos.UNIT_LINE)
if not self.announceEntireNewLine:
lineInfo.setEndPoint(newInfo,"endToStart")
if lineInfo.isCollapsed:
lineInfo.expand(textInfos.UNIT_CHARACTER)
onlyInitial=True
else:
onlyInitial=False
speech.speakTextInfo(lineInfo,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET,onlyInitialFields=onlyInitial,suppressBlanks=True)
示例3: script_moveToParent
def script_moveToParent(self, gesture):
# Make sure we're in a editable control
focus = api.getFocusObject()
if focus.role != controlTypes.ROLE_EDITABLETEXT:
ui.message("Not in an edit control.")
return
# Get the current indentation level
textInfo = focus.makeTextInfo(textInfos.POSITION_CARET)
textInfo.expand(textInfos.UNIT_LINE)
indentationLevel = len(textInfo.text) - len(textInfo.text.strip())
onEmptyLine = len(textInfo.text) == 1 #1 because an empty line will have the \n character
# Scan each line until we hit the start of the indentation block, the start of the edit area, or find a line with less indentation level
found = False
while textInfo.move(textInfos.UNIT_LINE, -2) == -2:
textInfo.expand(textInfos.UNIT_LINE)
newIndentation = len(textInfo.text) - len(textInfo.text.strip())
# Skip over empty lines if we didn't start on one.
if not onEmptyLine and len(textInfo.text) == 1:
continue
if newIndentation < indentationLevel:
# Found it
found = True
textInfo.updateCaret()
speech.speakTextInfo(textInfo, unit=textInfos.UNIT_LINE)
break
# If we didn't find it, tell the user
if not found:
ui.message("No parent of indentation block")
示例4: _caretMovementScriptHelper
def _caretMovementScriptHelper(self,gesture,unit,direction=None,posConstant=textInfos.POSITION_SELECTION,posUnit=None,posUnitEnd=False,extraDetail=False,handleSymbols=False):
oldInfo=self.makeTextInfo(posConstant)
info=oldInfo.copy()
info.collapse(end=self.isTextSelectionAnchoredAtStart)
if self.isTextSelectionAnchoredAtStart and not oldInfo.isCollapsed:
info.move(textInfos.UNIT_CHARACTER,-1)
if posUnit is not None:
# expand and collapse to ensure that we are aligned with the end of the intended unit
info.expand(posUnit)
try:
info.collapse(end=posUnitEnd)
except RuntimeError:
# MS Word has a "virtual linefeed" at the end of the document which can cause RuntimeError to be raised.
# In this case it can be ignored.
# See #7009
pass
if posUnitEnd:
info.move(textInfos.UNIT_CHARACTER,-1)
if direction is not None:
info.expand(unit)
info.collapse(end=posUnitEnd)
if info.move(unit,direction)==0 and isinstance(self,DocumentWithPageTurns):
try:
self.turnPage(previous=direction<0)
except RuntimeError:
pass
else:
info=self.makeTextInfo(textInfos.POSITION_FIRST if direction>0 else textInfos.POSITION_LAST)
self.selection=info
info.expand(unit)
if not willSayAllResume(gesture): speech.speakTextInfo(info,unit=unit,reason=controlTypes.REASON_CARET)
if not oldInfo.isCollapsed:
speech.speakSelectionChange(oldInfo,self.selection)
示例5: _caretMovementScriptHelper
def _caretMovementScriptHelper(self,gesture,unit,direction=None,posConstant=textInfos.POSITION_SELECTION,posUnit=None,posUnitEnd=False,extraDetail=False,handleSymbols=False):
oldInfo=self.makeTextInfo(posConstant)
info=oldInfo.copy()
info.collapse(end=not self._lastSelectionMovedStart)
if not self._lastSelectionMovedStart and not oldInfo.isCollapsed:
info.move(textInfos.UNIT_CHARACTER,-1)
if posUnit is not None:
info.expand(posUnit)
info.collapse(end=posUnitEnd)
if posUnitEnd:
info.move(textInfos.UNIT_CHARACTER,-1)
if direction is not None:
info.expand(unit)
info.collapse(end=posUnitEnd)
if info.move(unit,direction)==0 and isinstance(self,DocumentWithPageTurns):
try:
self.turnPage(previous=direction<0)
except RuntimeError:
pass
else:
info=self.makeTextInfo(textInfos.POSITION_FIRST if direction>0 else textInfos.POSITION_LAST)
self.selection=info
info.expand(unit)
if not willSayAllResume(gesture): speech.speakTextInfo(info,unit=unit,reason=controlTypes.REASON_CARET)
if not oldInfo.isCollapsed:
speech.speakSelectionChange(oldInfo,self.selection)
示例6: script_review_currentWord
def script_review_currentWord(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_WORD)
scriptCount=scriptHandler.getLastScriptRepeatCount()
if scriptCount==0:
speech.speakTextInfo(info,reason=speech.REASON_CARET,unit=textInfos.UNIT_WORD)
else:
speech.speakSpelling(info.text,useCharacterDescriptions=bool(scriptCount>1))
示例7: script_review_startOfLine
def script_review_startOfLine(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_LINE)
info.collapse()
api.setReviewPosition(info.copy())
info.expand(textInfos.UNIT_CHARACTER)
speech.speakMessage(_("left"))
speech.speakTextInfo(info,unit=textInfos.UNIT_CHARACTER,reason=speech.REASON_CARET)
示例8: script_tab
def script_tab(self,gesture):
oldBookmark=self.rootNVDAObject.makeTextInfo(textInfos.POSITION_SELECTION).bookmark
gesture.send()
noTimeout,newInfo=self.rootNVDAObject._hasCaretMoved(oldBookmark,timeout=1)
if not newInfo:
return
info=self.makeTextInfo(textInfos.POSITION_SELECTION)
if not info.isCollapsed:
speech.speakTextInfo(info,reason=controlTypes.REASON_FOCUS)
示例9: script_caret_moveByCell
def script_caret_moveByCell(self,gesture):
gesture.send()
info=self.makeTextInfo(textInfos.POSITION_SELECTION)
inTable=info._rangeObj.tables.count>0
isCollapsed=info.isCollapsed
if inTable:
info.expand(textInfos.UNIT_CELL)
speech.speakTextInfo(info,reason=controlTypes.REASON_FOCUS)
braille.handler.handleCaretMove(self)
示例10: script_review_previousLine
def script_review_previousLine(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_LINE)
info.collapse()
res=info.move(textInfos.UNIT_LINE,-1)
api.setReviewPosition(info.copy())
info.expand(textInfos.UNIT_LINE)
if res==0:
speech.speakMessage(_("top"))
speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=speech.REASON_CARET)
示例11: script_review_nextWord
def script_review_nextWord(self,gesture):
info=api.getReviewPosition().copy()
info.expand(textInfos.UNIT_WORD)
info.collapse()
res=info.move(textInfos.UNIT_WORD,1)
api.setReviewPosition(info.copy())
info.expand(textInfos.UNIT_WORD)
if res==0:
speech.speakMessage(_("bottom"))
speech.speakTextInfo(info,reason=speech.REASON_CARET,unit=textInfos.UNIT_WORD)
示例12: report
def report(self,readUnit=None):
info=self.textInfo
if readUnit:
fieldInfo = info.copy()
info.collapse()
info.move(readUnit, 1, endPoint="end")
if info.compareEndPoints(fieldInfo, "endToEnd") > 0:
# We've expanded past the end of the field, so limit to the end of the field.
info.setEndPoint(fieldInfo, "endToEnd")
speech.speakTextInfo(info, reason=controlTypes.REASON_FOCUS)
示例13: script_previousColumn
def script_previousColumn(self,gesture):
info=self.makeTextInfo("caret")
if not info._rangeObj.Information(wdWithInTable):
speech.speakMessage(_("not in table"))
return
if info._moveInTable(-1,0):
info.updateCaret()
info.expand(textInfos.UNIT_CELL)
speech.speakTextInfo(info,reason=speech.REASON_CARET)
else:
speech.speakMessage(_("edge of table"))
示例14: _changePageScriptHelper
def _changePageScriptHelper(self,gesture,previous=False):
if isScriptWaiting():
return
try:
self.turnPage(previous=previous)
except RuntimeError:
return
info=self.makeTextInfo(textInfos.POSITION_FIRST)
self.selection=info
info.expand(textInfos.UNIT_LINE)
if not willSayAllResume(gesture): speech.speakTextInfo(info,unit=textInfos.UNIT_LINE,reason=controlTypes.REASON_CARET)
示例15: moveToBookmark
def moveToBookmark(position):
obj = api.getFocusObject()
treeInterceptor=obj.treeInterceptor
if isinstance(treeInterceptor, BrowseModeDocumentTreeInterceptor) and not treeInterceptor.passThrough:
obj = treeInterceptor
bookmark = Offsets(position, position)
info = obj.makeTextInfo(bookmark)
info.updateSelection()
review.handleCaretMove(info)
speech.cancelSpeech()
info.move(textInfos.UNIT_LINE,1,endPoint="end")
speech.speakTextInfo(info,reason=controlTypes.REASON_CARET)