python类message()的实例源码

systemsettings.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def event_liveRegionChange(self, obj, nextHandler):
        if isinstance(obj, UIA) and obj.name != self._nameChangeCache:
            automationID = obj.UIAElement.cachedAutomationID
            try:
                # Don't repeat the fact that update download/installation is in progress if progress bar beep is on.
                if ((automationID == "SystemSettings_MusUpdate_UpdateStatus_DescriptionTextBlock" and obj.previous.value <= "0")
                # For search progress bar, do not repeat it.
                or (automationID == "ProgressBar")
                # Do not announce "result not found" error unless have to.
                or (automationID == "NoResultsFoundTextBlock" and obj.parent.UIAElement.cachedAutomationID == "StatusTextPopup")
                # But announce individual update progress in build 16215 and later.
                or ("ApplicableUpdate" in automationID and automationID.endswith("_ContextDescriptionTextBlock"))):
                    self._nameChangeCache = obj.name
                    # Until the spacing problem is fixed for update label...
                    if "ApplicableUpdate" in automationID and automationID.endswith("_ContextDescriptionTextBlock"):
                        ui.message(" ".join([obj.parent.name, obj.name]))
                    else:
                        ui.message(obj.name)
                    # And no, never allow double-speaking (an ugly hack).
                    return
            except AttributeError:
                pass
skypeapp.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def locateElement(self, automationID):
        # Foreground isn't reliable.
        fg = api.getForegroundObject()
        if fg.getChild(1).childCount > 0:
            screenContent = fg.getChild(1)
        else:
            screenContent = fg.getChild(2)
        # Thanks to My Peple in Fall Creators Update, screen content so far could actually be the title bar, and the actual foreground window is next door.
        # In other words, Skype window is embedded inside My People window.
        if screenContent.UIAElement.cachedAutomationID == "TitleBar":
            # The following traversal path may change in future builds.
            screenContent = screenContent.next.simpleLastChild.simpleFirstChild
        # Element placement (according to UIA changes from time to time.
        # Wish there is a more elegant way to do this...
        for element in screenContent.children:
            if isinstance(element, UIA) and element.UIAElement.cachedAutomationID == automationID:
                return element
        return None

    # Name change cache (yet again)
    # In some cases, Skype message fires name change, and a related element fires live region changed event.
devenv.py 文件源码 项目:visualStudioAddon 作者: mohammad-suliman 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def event_nameChange(self):
        #a nameChange event is fired by breakpoint UI control when the caret reaches a line with breakpoint, so, we rely on this to announce breakpoints
        global caretMovedToDifferentLine
        if not caretMovedToDifferentLine:
            #a nameChange event can be fired multiple times when moving by character within the same line, so, return if we already announced the break point for the current line 
            return
        caretMovedToDifferentLine = False
        currentLineNum = _getCurLineNumber()
        BPLineNum = self._getLineNumber()
        if currentLineNum == 0 or BPLineNum == 0 \
        or currentLineNum != BPLineNum:
            return
        if config.conf["visualStudio"]["beepOnBreakpoints"]:
            tones.beep(1000, 50)
        if not config.conf["visualStudio"]["announceBreakpoints"]:
            return
        message = _("breakpoint")
        state = re.search(REG_GET_BREAKPOINT_STATE, self.name)
        if  state:
            message += "  " 
            message += state.group()
        ui.message(message)
__init__.py 文件源码 项目:announceScope 作者: ctoth 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def script_announce_scope(self, gesture):
        info=api.getReviewPosition().copy()
        info.expand(textInfos.UNIT_LINE)
        line_text = info.text
        if not line_text:
            ui.message(_("No text found"))
            return
        char, position = find_indent(line_text)
        if position == 0:
            ui.message(_("Not indented"))
            return
        for line in previous_lines(info):
            prev_line_text = line.text
            if not prev_line_text.strip():
                continue
            new_char, new_position = find_indent(prev_line_text)
            if new_position < position:
                if new_position == 0 or new_char == char:
                    ui.message(prev_line_text)
                    return
dragonbar.py 文件源码 项目:dictationbridge-nvda 作者: dictationbridge 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def flashRightTextChanged(self, obj):
        text = obj.name
        if not text:
            return
        if self.lastFlashRightText == text:
            return
        self.lastFlashRightText = text
        mOff="Dragon\'s microphone is off;"
        mOn="Normal mode: You can dictate and use voice"
        mSleep="The microphone is asleep;"
        if mOn in text:
            ui.message("Dragon mic on")
        elif mOff in text:
            ui.message("Dragon mic off")
        elif mSleep in text:
            ui.message("Dragon sleeping")
lambdaEdit.py 文件源码 项目:lambdaNvda 作者: lambda-nvda 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def script_switch_flatMode(self,gesture) :
        val = config.conf['lambda']['brailleFlatMode'] = not config.conf['lambda']['brailleFlatMode']
        #Translators: This determines whether to use API or DisplayMode to render the editor window on a braille display. It is a toggle (on/off)
        flatModeMessage = _("flat mode ")
        self.TextInfo = self._get_TextInfo()    
        ui.message(flatModeMessage + ((lambda x: shMsg.GLB_ON if x else shMsg.GLB_OFF)(val)))
        braille.handler.mainBuffer.clear()
        braille.handler.handleGainFocus(self)
    #This script set the desired textInfo for braille, when flat mode is on, the LambdaEditorFlatTextInfo is used, otherwise the LambdaEditorTextInfo is set.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def message(self, text):
        import speech, braille
        braille.handler.message(text)
        if self.appModule.commandAnnouncement:
            speech.speakMessage(text)

    # A master function to obtain needed info from status bars.
    # #17.05: because this is prone to failure, insert debug messages if asked.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def script_dropStartMarker(self, gesture):
        gesture.send()
        # Translators: The start marker position for selecting parts of the audio track (example output: "Start: 0.00").
        self.message(_("Start: {startMarkerPos}").format(startMarkerPos = self.getAudioSelectionParsed()[0]))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def script_dropFinishMarker(self, gesture):
        gesture.send()
        # Translators: The finish marker position for selecting parts of the audio track (example output: "Finish: 5.00").
        self.message(_("Finish: {finishMarkerPos}").format(finishMarkerPos = self.getAudioSelectionParsed()[2]))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def script_playSelection(self, gesture):
        gesture.send()
        # Translators: Presented when selected audio is playing.
        self.message(_("Play selection"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def script_selectAll(self, gesture):
        gesture.send()
        # Translators: Presented when all parts of the audio track is selected.
        self.message(_("Select All"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def script_dropCueAtStartMarker(self, gesture):
        gesture.send()
        # Translators: Presented when audio cue is dropped at the start marker position.
        self.message(_("Cue dropped at start marker"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def script_dropCueAtFinishMarker(self, gesture):
        gesture.send()
        # Translators: Presented when an audio cue is dropped at the finish marker position.
        self.message(_("Cue dropped at finish marker"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def script_moveStartMarkerToNextCuePos(self, gesture):
        gesture.send()
        # Translators: Presented when the start marker is moved to the next cue position.
        self.message(_("Start marker at next cue"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def script_moveStartMarkerToPrevCuePos(self, gesture):
        gesture.send()
        # Translators: Presented when the start marker is moved to the next cue position.
        self.message(_("Start marker at previous cue"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def script_moveFinishMarkerToNextCuePos(self, gesture):
        gesture.send()
        # Translators: Presented when the finish marker is moved to the next cue position.
        self.message(_("Finish marker at next cue"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def script_deleteSelection(self, gesture):
        gesture.send()
        # Translators: Presented when audio selection is deleted.
        self.message(_("deleted"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def script_play(self, gesture):
        gesture.send()
        # Translators: Presented when a track is playing in Goldwave.
        self.message(_("play"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def script_rewind(self, gesture):
        gesture.send()
        # Translators: Presented when a track is rewinding in Goldwave.
        self.message(_("rewind"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def script_forward(self, gesture):
        gesture.send()
        # Translators: Presented when fast forwarding a track in Goldwave.
        self.message(_("fast forward"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def script_pause(self, gesture):
        gesture.send()
        # Translators: Presented when pausing a track in Goldwave.
        self.message(_("pause"))
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def script_startRecord(self, gesture):
        gesture.send()
        # Translators: Presented when starting recording in Goldwave.
        self.message(_("record"))

    # Audio position scripts: markers, selection duration.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def script_announceAudioPosition(self, gesture):
        # Shouldn't say anything unless in audio editing view.
        self.message(self.getAudioPos())
    # Translators: Input help mode message for a Goldwave command.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def script_announceAudioSelection(self, gesture):
        # Parse this string to get individual info such as marker positions.
        audioSelectionParsed = self.getAudioSelectionParsed()
        if not audioSelectionParsed:
            # Translators: Presented when there is no audio selection summary available.
            self.message(_("Unable to obtain audio selection summary. Please close and reopen the audio track."))
        else:
            # Translators: The audio selection summary message (example output: "0.00 to 1.00 (1.00)").
            self.message(_("{audioSelectionStart} to {audioSelectionEnd} {audioSelectionLength}").format(audioSelectionStart = audioSelectionParsed[0], audioSelectionEnd = audioSelectionParsed[2], audioSelectionLength = audioSelectionParsed[3]))
    # Translators: Input help mode message for a Goldwave command.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def script_announceTrackLength(self, gesture):
        trackLengthSTR = self.getTrackLength()
        if not trackLengthSTR:
            # Translators: Presented when there is no track length information.
            self.message(_("Track length is unavailable. Please close and reopen the audio track."))
        else:
            self.message(_("Track length: {trackLength}").format(trackLength = trackLengthSTR))
    # Translators: Input help mode message for a Goldwave command.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def script_announceRemainingTime(self, gesture):
        audioPos = self.getAudioPos(raw=True)
        if not audioPos or " " in audioPos or not self.getTrackLength():
            # Translators: An error message presented when remaining time cannot be anounced.
            ui.message(_("Cannot tell you remaining time for the current track"))
        else:
            if ":" in audioPos:
                ui.message(self.getRemainingTime(audioPos))
            elif float(audioPos) == 0.0:
                ui.message(self.getTrackLength())
            else:
                ui.message(self.getRemainingTime(audioPos))

    # Audio channels and zoom level.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def script_announceZoomLevel(self, gesture):
        # Translators: Presented to indicate audio selection zoom level (example output: "Zoom level: 10.000").
        self.message(_("Zoom level: {zoomLevel}").format(zoomLevel = self.getZoomLevel()))
    # Translators: Input help mode message for a Goldwave command.
goldwave.py 文件源码 项目:goldWave 作者: josephsl 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def script_toggleCommandAnnouncement(self, gesture):
        focus = api.getFocusObject()
        if focus.windowClassName not in ("TWaveView", "TSoundForm"):
            # Translators: Presented when command announcement toggle is unavailable.
            ui.message(_("You need to be in sound window to toggle command announcement"))
        else:
            self.commandAnnouncement = not self.commandAnnouncement
            # Handle the announcement of this script separately, since we need to speak even when false.
            if self.commandAnnouncement:
                # Translators: Presented when command announcement messages are turned on in Goldwave.
                ui.message(_("command announcement on"))
            else:
                # Translators: Presented when command announcement messages are turned off in Goldwave.
                ui.message(_("command announcement off"))
    # Translators: Input help mode message for command announcement command in Goldwave.
__init__.py 文件源码 项目:nvda-ocr 作者: nvaccess 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def script_ocrNavigatorObject(self, gesture):
        nav = api.getNavigatorObject()
        left, top, width, height = nav.location
        img = ImageGrab.grab(bbox=(left, top, left + width, top + height))
        # Tesseract copes better if we convert to black and white...
        img = img.convert(mode='L')
        # and increase the size.
        img = img.resize((width * IMAGE_RESIZE_FACTOR, height * IMAGE_RESIZE_FACTOR), Image.BICUBIC)
        baseFile = os.path.join(tempfile.gettempdir(), "nvda_ocr")
        try:
            imgFile = baseFile + ".bmp"
            img.save(imgFile)

            ui.message(_("Running OCR"))
            lang = getConfig()['language']
            # Hide the Tesseract window.
            si = subprocess.STARTUPINFO()
            si.dwFlags = subprocess.STARTF_USESHOWWINDOW
            si.wShowWindow = subprocess.SW_HIDE
            subprocess.check_call((TESSERACT_EXE, imgFile, baseFile, "-l", lang, "hocr"),
                startupinfo=si)
        finally:
            try:
                os.remove(imgFile)
            except OSError:
                pass
        try:
            hocrFile = baseFile + ".html"

            parser = HocrParser(file(hocrFile).read(),
                left, top)
        finally:
            try:
                os.remove(hocrFile)
            except OSError:
                pass

        # Let the user review the OCR output.
        nav.makeTextInfo = lambda position: OcrTextInfo(nav, position, parser)
        api.setReviewPosition(nav.makeTextInfo(textInfos.POSITION_FIRST))
        ui.message(_("Done"))
__init__.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def event_suggestionsOpened(self):
        super(SearchField, self).event_suggestionsOpened()
        # Announce number of items found (except in Start search box where the suggestions are selected as user types).
        # Oddly, Edge's address omnibar returns 0 for suggestion count when there are clearly suggestions (implementation differences).
        # Because inaccurate count could be announced (when users type, suggestion count changes), thus announce this if position info reporting is enabled.
        if config.conf["presentation"]["reportObjectPositionInformation"]:
            if self.UIAElement.cachedAutomationID == "TextBox" or self.UIAElement.cachedAutomationID == "SearchTextBox" and self.appModule.appName != "searchui":
                # Item count must be the last one spoken.
                suggestionsCount = self.controllerFor[0].childCount
                suggestionsMessage = "1 suggestion" if suggestionsCount == 1 else "%s suggestions"%suggestionsCount
                queueHandler.queueFunction(queueHandler.eventQueue, ui.message, suggestionsMessage)


问题


面经


文章

微信
公众号

扫码关注公众号