コード例 #1
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def next_word(self) -> bool:
        value: str = "".join(self.input)
        index: str = 0
        word: str = ""

        try:
            index = value.index(" ", self.position, len(value))
        except ValueError:
            index = len(value)

        if index < len(value):
            self.position = index + 1
            try:
                index = value.index(" ", self.position, len(value))
            except ValueError:
                index = len(value)

            word = value[self.position:index]

            if self.hidden:
                word = "Star " * len(word)
            elif word == "":
                word = "space"
        else:
            self.position = index
            word = "blank"

        if word == " ":
            word = "space"

        speech_manager.output(word, interrupt=True, log_message=False)
        self.play_navigate_sound()

        self.clear_selection()
        return EVENT_HANDLED
コード例 #2
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def output_value(self) -> bool:
        if not self.hidden:
            speech_manager.output(self.get_value(), interrupt=True, log_message=False)
        else:
            speech_manager.output("star" * len(self.input), interrupt=True, log_message=False)

        return EVENT_HANDLED
コード例 #3
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def move_word_selection_right(self) -> bool:
        value: str = self.get_value()
        index: str = 0
        word: str = ""
        selection_text: str = "Selected"
        previous_position: int = self.position

        if self.selecting_left:
            selection_text = "Unselected"

        try:
            index = value.index(" ", self.position, len(value))
        except ValueError:
            index = len(value)

        if self.position < len(value) and index <= len(value):
            word = value[self.position:index]

            if self.hidden:
                word = "Star " * len(word)
            elif word == " " or (word == "" and value[self.position] == " "):
                word = "space"

            if index >= len(value):
                self.position = index
            else:
                self.position = index + 1
            speech_manager.output(word + " " + selection_text, interrupt=True, log_message=False)
            self.set_right_selection(previous_position, self.position)

        return EVENT_HANDLED
コード例 #4
0
ファイル: checkbox.py プロジェクト: tbreitenfeldt/audio_ui
 def setup(self,
           change_state: Callable[[str, any], None],
           interrupt_speech: str = True) -> bool:
     super().setup(change_state, interrupt_speech)
     output_value: str = "Checked" if self.value else "Unchecked"
     speech_manager.output(output_value, interrupt=False, log_message=False)
     return True
コード例 #5
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def previous_word(self) -> bool:
        value: str = "".join(self.input)
        index: str = 0
        word: str = ""

        if self.position > 0:
            if self.input[self.position-1] == " ":
                self.position -= 1

            try:
                index = value.rindex(" ", 0, self.position)
            except ValueError:
                index = 0

            self.position = index
            if self.position > 0:
                self.position += 1

        try:
            index = value.index(" ", self.position, len(value))
        except ValueError:
            index = len(value)

        word = value[self.position:index]
        if self.hidden:
            word = "Star " * len(word)
        elif word == " " or (word == "" and value[self.position] == " "):
            word = "space"

        speech_manager.output(word, interrupt=True, log_message=False)
        self.play_navigate_sound()

        self.clear_selection()
        return EVENT_HANDLED
コード例 #6
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def move_word_selection_left(self) -> bool:
        value: str = "".join(self.input)
        index: str = 0
        word: str = ""
        selection_text: str = "Selected"
        previous_position: int = self.position

        if self.selecting_right:
            selection_text = "Unselected"

        if self.position > 0:
            if self.input[self.position-1] == " ":
                self.position -= 1

            try:
                index = value.rindex(" ", 0, self.position)
            except ValueError:
                index = 0

            word = value[index:self.position]
            self.position = index
            if self.position > 0:
                self.position += 1

            if self.hidden:
                word = "Star " * len(word)
            elif word == " " or (word == "" and value[self.position] == " "):
                word = "space"

            speech_manager.output(word + " " + selection_text, interrupt=True, log_message=False)
            self.set_left_selection(self.position, previous_position)

        return EVENT_HANDLED
コード例 #7
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def select_all(self) -> bool:
        if self.input and self.left_selection_index != 0 and self.right_selection_index != len(self.input):
            self.left_selection_index = 0
            self.right_selection_index = len(self.input)
            self.selecting_right = True
            self.position = len(self.input)
            speech_manager.output(self.get_value() + " Selected", interrupt=True, log_message=False)

        return EVENT_HANDLED
コード例 #8
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def clear_selection(self) -> None:
        if self.left_selection_index > -1 or self.right_selection_index > -1:
            if self.left_selection_index != self.right_selection_index:
                speech_manager.output("Unselected", interrupt=False, log_message=False)

            self.left_selection_index = -1
            self.right_selection_index = -1
            self.selecting_left = False
            self.selecting_right = False
コード例 #9
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def paste_from_clipboard(self) -> bool:
        value: str = pyperclip.paste()

        if len(value) + len(self.input) <= self.text_box_size:
            if self.is_selected():
                self.delete_selection()

            self.input[self.position:self.position] = list(value)
            self.position += len(value)
            speech_manager.output("Pasted " + value, interrupt=True, log_message=False)

        return EVENT_HANDLED
コード例 #10
0
ファイル: element.py プロジェクト: tbreitenfeldt/audio_ui
    def setup(self, change_state: Callable[[str, any], None],
              interrupt_speech) -> bool:
        self.change_state = change_state

        if self.title:
            speech_manager.output(self.title + " " + self.type,
                                  interrupt=interrupt_speech,
                                  log_message=False)

        if self.use_key_handler:
            self.push_handlers(self.key_handler)

        return True
コード例 #11
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def delete_previous_character(self) -> bool:
        if self.input:
            if self.is_selected():
                self.delete_selection()

                if self.position == 0:
                    speech_manager.output("blank", interrupt=True, log_message=False)
                else:
                    output_value: str = self.input[self.position-1]
                    if output_value == " ":
                        output_value = "space"
                    speech_manager.output(output_value, interrupt=True, log_message=False)

            elif self.position > 0:
                output_value: str = self.input[self.position-1]

                if self.hidden:
                    output_value = "star"
                elif output_value == " ":
                    output_value = "space"
                elif output_value.isupper():
                    output_value = "Cap " + output_value

                speech_manager.output(output_value, interrupt=True, log_message=False)
                del self.input[self.position-1]
                self.position -= 1
                self.play_delete_sound()
        else:
            speech_manager.output("Blank", interrupt=True, log_message=False)

        return EVENT_HANDLED
コード例 #12
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def setup(self, change_state: Callable[[str, any], None], interrupt_speech: bool = True) ->bool:
        super().setup(change_state, interrupt_speech)

        if self.music:
            audio_manager.load_music(self.music)
            audio_manager.play_music(loops=-1)
        if self.open_sound != "":
            audio_manager.play_sound(self.open_sound)

        self.play_open_sound()

        output_value: str = self.get_value()
        if self.get_value() == "":
            output_value = "Blank"
        if self.read_only:
            output_value = "Read Only " + output_value

        speech_manager.output(output_value, interrupt=False, log_message=False)
        return True
コード例 #13
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def type_character(self, character: str) -> bool:
        if self.is_selected():
            self.delete_selection()

        if len(self.input) < self.text_box_size:
            self.input.insert(self.position, character)
            self.position += 1

            output_value: str = character

            if self.hidden:
                output_value = "star"
            elif character == " ":
                if self.echo_words and self.position != 1:
                    value: str = "".join(self.input)
                    start_of_word: int = -1

                    try:
                        start_of_word = value.rindex(" ", 0, self.position-1)
                    except ValueError:
                        start_of_word = 0

                    output_value = value[start_of_word:self.position - 1]
                    if output_value == " ":
                        output_value = "space"
                else:
                    output_value = "space"

            if character == " " or self.echo_characters:
                if output_value.isupper():
                    speech_manager.output("Cap " + output_value, interrupt=True, log_message=False)
                else:
                    speech_manager.output(output_value, interrupt=True, log_message=False)

        self.play_typing_sound()

        return EVENT_HANDLED
コード例 #14
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def move_home(self) -> bool:
        self.position = 0
        if not self.input:
                speech_manager.output("blank", interrupt=True, log_message=False)
        elif self.hidden:
                speech_manager.output("star", interrupt=True, log_message=False)
        else:
                if self.input[self.position] == " ":
                    speech_manager.output("space", interrupt=True, log_message=False)
                else:
                    output_value = self.input[self.position]
                    if output_value.isupper():
                        output_value = "Cap " + self.input[self.position]
                    speech_manager.output(output_value, interrupt=True, log_message=False)

        self.clear_selection()
        return EVENT_HANDLED
コード例 #15
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def move_letter_selection_right(self) -> bool:
        selection_text: str = "Selected"

        if self.selecting_left:
            selection_text = "Unselected"
        if self.position + 1 <= len(self.input):
            if self.hidden:
                speech_manager.output("star " + selection_text, interrupt=True, log_message=False)
            else:
                if self.input[self.position] == " ":
                    speech_manager.output("space " + selection_text, interrupt=True, log_message=False)
                else:
                    output_value: str = self.input[self.position] + " " + selection_text
                    if output_value.isupper():
                        output_value = "Cap " + self.input[self.position]
                    speech_manager.output(output_value, interrupt=True, log_message=False)

            previous_position: int = self.position
            self.position += 1
            self.set_right_selection(previous_position, self.position)

        return EVENT_HANDLED
コード例 #16
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def move_end(self) -> bool:
        self.position = len(self.input)
        speech_manager.output("blank", interrupt=True, log_message=False)

        self.clear_selection()
        return EVENT_HANDLED
コード例 #17
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def copy_to_clipboard(self) -> bool:
        if self.is_selected():
            pyperclip.copy(self.get_value()[self.left_selection_index:self.right_selection_index])
            speech_manager.output("Copied selection to clipboard", interrupt=True, log_message=False)

        return EVENT_HANDLED
コード例 #18
0
ファイル: window.py プロジェクト: tbreitenfeldt/audio_ui
 def caption(self, caption: str) -> None:
     speech_manager.output(self._caption, interrupt=True, log_message=False)
     self._caption = caption
     self.pyglet_window.set_caption(caption)
コード例 #19
0
 def setup(self, change_state: Callable[[str, any], None], interrupt_speech: bool = True) -> bool:
     super().setup(change_state, interrupt_speech)
     speech_manager.output(self.items[self.position], interrupt=False, log_message=False)
     return True
コード例 #20
0
 def on_action(self) -> bool:
     self.position = (self.position + 1) % len(self.items)
     self.value = self.items[self.position]
     speech_manager.output(self.value, interrupt=True, log_message=False)
     return EVENT_HANDLED
コード例 #21
0
ファイル: text_box.py プロジェクト: tbreitenfeldt/audio_ui
    def previous_character(self) -> bool:
        if self.left_selection_index == 0 and self.right_selection_index == len(self.input):
            self.position = 0
            speech_manager.output(self.input[self.position], interrupt=True, log_message=False)
        elif self.position - 1 < 0:
            self.play_border_sound()

            if self.input:
                if self.input[0] == " ":
                    speech_manager.output("space", interrupt=True, log_message=False)
                else:
                    speech_manager.output(self.input[0], interrupt=True, log_message=False)
            else:
                speech_manager.output("blank", interrupt=True, log_message=False)
        else:
            self.position -= 1

            self.play_navigate_sound()
            if self.hidden:
                speech_manager.output("star", interrupt=True, log_message=False)
            else:
                if self.input[self.position] == " ":
                    speech_manager.output("space", interrupt=True, log_message=False)
                else:
                    output_value: str = self.input[self.position]
                    if output_value.isupper():
                        output_value = "Cap " + output_value
                    speech_manager.output(output_value, interrupt=True, log_message=False)

            self.play_navigate_sound()

        self.clear_selection()
        return EVENT_HANDLED
コード例 #22
0
ファイル: checkbox.py プロジェクト: tbreitenfeldt/audio_ui
 def on_action(self) -> bool:
     self.value = not self.value
     output_value: str = "Checked" if self.value else "Unchecked"
     speech_manager.output(output_value, interrupt=True, log_message=False)
     self.play_toggle_sounds()
     return EVENT_HANDLED
コード例 #23
0
ファイル: window.py プロジェクト: tbreitenfeldt/audio_ui
    def run_speech_introduction(self) -> None:
        speech_manager.output(self._caption, interrupt=True, log_message=False)

        if self.state_machine.size() > 0:
            first_state_key: str = next(iter(self.state_machine.states))
            self.state_machine.change(first_state_key)