예제 #1
0
    def on_type(*args) -> None:
        """Re-search whenever text is typed."""
        nonlocal refresh_tim, result
        text = search_var.get().casefold()
        words = text.split()
        if not words:
            refresh_cback(None)
            return

        found: set[tuple[str, int]] = set()
        *words, last = words
        for word in words:
            try:
                found |= word_to_ids[word]
            except KeyError:
                pass
        if last:
            try:
                for group in word_to_ids.itervalues(last):
                    found |= group
            except KeyError:
                pass

        # The callback causes us to be deselected, so delay it until the user
        # stops typing.
        result = found
        if refresh_tim is not None:
            TK_ROOT.after_cancel(refresh_tim)
        refresh_tim = TK_ROOT.after(500, trigger_cback)
예제 #2
0
 def exit_handler(e):
     """When the user leaves, cancel the event."""
     # We only want to cancel if the event hasn't expired already
     nonlocal event_id
     window.withdraw()
     if event_id is not None:
         TK_ROOT.after_cancel(event_id)
예제 #3
0
    def stop(self) -> None:
        """Cancel the music, if it's playing."""
        if self.player is not None:
            self.player.pause()
            self.player = None
            self.stop_callback()

        if self.after is not None:
            TK_ROOT.after_cancel(self.after)
            self.after = None
예제 #4
0
 def on_leave(slot: dragdrop.Slot[Signage]) -> None:
     """Reset the visible sign when left."""
     nonlocal hover_toggle_id, hover_sign
     name_label['text'] = ''
     hover_sign = None
     if hover_toggle_id is not None:
         TK_ROOT.after_cancel(hover_toggle_id)
         hover_toggle_id = None
     img.apply(preview_left, IMG_BLANK)
     img.apply(preview_right, IMG_BLANK)
예제 #5
0
 def on_leave(slot: dragdrop.Slot[Signage]) -> None:
     """Reset the visible sign when left."""
     nonlocal hover_toggle_id, hover_sign
     name_label['text'] = ''
     hover_sign = None
     if hover_toggle_id is not None:
         TK_ROOT.after_cancel(hover_toggle_id)
         hover_toggle_id = None
     preview_left['image'] = blank_sign
     preview_right['image'] = blank_sign
예제 #6
0
파일: sound.py 프로젝트: seagemgames/BEE2.4
        def stop(self) -> None:
            """Cancel the music, if it's playing."""
            if self.sample is None:
                return

            self.sample.pause()
            self.sample = None
            self._close_handles()
            self.stop_callback()

            if self.after is not None:
                TK_ROOT.after_cancel(self.after)
                self.after = None